ag-psd 31.0.2 → 32.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.
Files changed (1105) hide show
  1. package/.v8-cache/v24.13.1-x64-cf738c9d/acc36e66 +0 -0
  2. package/.v8-cache/v24.13.1-x64-cf738c9d/b3c2fab7 +0 -0
  3. package/.v8-cache/v24.13.1-x64-cf738c9d/cfc49f4f +0 -0
  4. package/.v8-cache/v24.7.0-x64-ef5a0af0/000a1de6 +0 -0
  5. package/.v8-cache/v24.7.0-x64-ef5a0af0/00b1f5b3 +0 -0
  6. package/.v8-cache/v24.7.0-x64-ef5a0af0/00d0e0b4 +0 -0
  7. package/.v8-cache/v24.7.0-x64-ef5a0af0/012a5efb +0 -0
  8. package/.v8-cache/v24.7.0-x64-ef5a0af0/012e069a +0 -0
  9. package/.v8-cache/v24.7.0-x64-ef5a0af0/0139d484 +0 -0
  10. package/.v8-cache/v24.7.0-x64-ef5a0af0/01f25b65 +0 -0
  11. package/.v8-cache/v24.7.0-x64-ef5a0af0/024691e5 +0 -0
  12. package/.v8-cache/v24.7.0-x64-ef5a0af0/0274927e +0 -0
  13. package/.v8-cache/v24.7.0-x64-ef5a0af0/02a30dfa +0 -0
  14. package/.v8-cache/v24.7.0-x64-ef5a0af0/02d69852 +0 -0
  15. package/.v8-cache/v24.7.0-x64-ef5a0af0/031f460b +0 -0
  16. package/.v8-cache/v24.7.0-x64-ef5a0af0/034093e8 +0 -0
  17. package/.v8-cache/v24.7.0-x64-ef5a0af0/039f982e +0 -0
  18. package/.v8-cache/v24.7.0-x64-ef5a0af0/03e19709 +0 -0
  19. package/.v8-cache/v24.7.0-x64-ef5a0af0/045b1dc4 +0 -0
  20. package/.v8-cache/v24.7.0-x64-ef5a0af0/04d897f8 +0 -0
  21. package/.v8-cache/v24.7.0-x64-ef5a0af0/05135617 +0 -0
  22. package/.v8-cache/v24.7.0-x64-ef5a0af0/052768c8 +0 -0
  23. package/.v8-cache/v24.7.0-x64-ef5a0af0/05330103 +0 -0
  24. package/.v8-cache/v24.7.0-x64-ef5a0af0/0539658f +0 -0
  25. package/.v8-cache/v24.7.0-x64-ef5a0af0/0561f0be +0 -0
  26. package/.v8-cache/v24.7.0-x64-ef5a0af0/056407a9 +0 -0
  27. package/.v8-cache/v24.7.0-x64-ef5a0af0/0585b7bb +0 -0
  28. package/.v8-cache/v24.7.0-x64-ef5a0af0/05b78f6b +0 -0
  29. package/.v8-cache/v24.7.0-x64-ef5a0af0/05b95c81 +0 -0
  30. package/.v8-cache/v24.7.0-x64-ef5a0af0/061ebf08 +0 -0
  31. package/.v8-cache/v24.7.0-x64-ef5a0af0/064f1d49 +0 -0
  32. package/.v8-cache/v24.7.0-x64-ef5a0af0/06cc3e45 +0 -0
  33. package/.v8-cache/v24.7.0-x64-ef5a0af0/07041e8e +0 -0
  34. package/.v8-cache/v24.7.0-x64-ef5a0af0/0742f03e +0 -0
  35. package/.v8-cache/v24.7.0-x64-ef5a0af0/0778b960 +0 -0
  36. package/.v8-cache/v24.7.0-x64-ef5a0af0/079604d9 +0 -0
  37. package/.v8-cache/v24.7.0-x64-ef5a0af0/07dfdaca +0 -0
  38. package/.v8-cache/v24.7.0-x64-ef5a0af0/08211eb2 +0 -0
  39. package/.v8-cache/v24.7.0-x64-ef5a0af0/08f84914 +0 -0
  40. package/.v8-cache/v24.7.0-x64-ef5a0af0/090dbd98 +0 -0
  41. package/.v8-cache/v24.7.0-x64-ef5a0af0/092e59e1 +0 -0
  42. package/.v8-cache/v24.7.0-x64-ef5a0af0/09fc8723 +0 -0
  43. package/.v8-cache/v24.7.0-x64-ef5a0af0/09feaf7d +0 -0
  44. package/.v8-cache/v24.7.0-x64-ef5a0af0/0aa8bbea +0 -0
  45. package/.v8-cache/v24.7.0-x64-ef5a0af0/0aaed951 +0 -0
  46. package/.v8-cache/v24.7.0-x64-ef5a0af0/0ad8fa6e +0 -0
  47. package/.v8-cache/v24.7.0-x64-ef5a0af0/0b4d326d +0 -0
  48. package/.v8-cache/v24.7.0-x64-ef5a0af0/0bdcb794 +0 -0
  49. package/.v8-cache/v24.7.0-x64-ef5a0af0/0c33d3b3 +0 -0
  50. package/.v8-cache/v24.7.0-x64-ef5a0af0/0c641507 +0 -0
  51. package/.v8-cache/v24.7.0-x64-ef5a0af0/0c877a23 +0 -0
  52. package/.v8-cache/v24.7.0-x64-ef5a0af0/0c9093b8 +0 -0
  53. package/.v8-cache/v24.7.0-x64-ef5a0af0/0cc76730 +0 -0
  54. package/.v8-cache/v24.7.0-x64-ef5a0af0/0d17afb7 +0 -0
  55. package/.v8-cache/v24.7.0-x64-ef5a0af0/0d34de12 +0 -0
  56. package/.v8-cache/v24.7.0-x64-ef5a0af0/0d38cfd1 +0 -0
  57. package/.v8-cache/v24.7.0-x64-ef5a0af0/0dad9f05 +0 -0
  58. package/.v8-cache/v24.7.0-x64-ef5a0af0/0dc02503 +0 -0
  59. package/.v8-cache/v24.7.0-x64-ef5a0af0/0df68674 +0 -0
  60. package/.v8-cache/v24.7.0-x64-ef5a0af0/0e15ac0b +0 -0
  61. package/.v8-cache/v24.7.0-x64-ef5a0af0/0e41bec3 +0 -0
  62. package/.v8-cache/v24.7.0-x64-ef5a0af0/0e897f0a +0 -0
  63. package/.v8-cache/v24.7.0-x64-ef5a0af0/0ec2e273 +0 -0
  64. package/.v8-cache/v24.7.0-x64-ef5a0af0/0f0a2045 +0 -0
  65. package/.v8-cache/v24.7.0-x64-ef5a0af0/0f44aab6 +0 -0
  66. package/.v8-cache/v24.7.0-x64-ef5a0af0/106347f0 +0 -0
  67. package/.v8-cache/v24.7.0-x64-ef5a0af0/1065c98c +0 -0
  68. package/.v8-cache/v24.7.0-x64-ef5a0af0/10cb14e2 +0 -0
  69. package/.v8-cache/v24.7.0-x64-ef5a0af0/10d12405 +0 -0
  70. package/.v8-cache/v24.7.0-x64-ef5a0af0/1130885f +0 -0
  71. package/.v8-cache/v24.7.0-x64-ef5a0af0/11b78352 +0 -0
  72. package/.v8-cache/v24.7.0-x64-ef5a0af0/11ca6000 +0 -0
  73. package/.v8-cache/v24.7.0-x64-ef5a0af0/11e0bcf8 +0 -0
  74. package/.v8-cache/v24.7.0-x64-ef5a0af0/12804b67 +0 -0
  75. package/.v8-cache/v24.7.0-x64-ef5a0af0/128ffeb6 +0 -0
  76. package/.v8-cache/v24.7.0-x64-ef5a0af0/1307c983 +0 -0
  77. package/.v8-cache/v24.7.0-x64-ef5a0af0/133aee2d +0 -0
  78. package/.v8-cache/v24.7.0-x64-ef5a0af0/13aac3d1 +0 -0
  79. package/.v8-cache/v24.7.0-x64-ef5a0af0/13fbcebc +0 -0
  80. package/.v8-cache/v24.7.0-x64-ef5a0af0/14015561 +0 -0
  81. package/.v8-cache/v24.7.0-x64-ef5a0af0/1425bd90 +0 -0
  82. package/.v8-cache/v24.7.0-x64-ef5a0af0/14345a1b +0 -0
  83. package/.v8-cache/v24.7.0-x64-ef5a0af0/149c4644 +0 -0
  84. package/.v8-cache/v24.7.0-x64-ef5a0af0/1520be33 +0 -0
  85. package/.v8-cache/v24.7.0-x64-ef5a0af0/1527d78f +0 -0
  86. package/.v8-cache/v24.7.0-x64-ef5a0af0/15453dd8 +0 -0
  87. package/.v8-cache/v24.7.0-x64-ef5a0af0/15a59607 +0 -0
  88. package/.v8-cache/v24.7.0-x64-ef5a0af0/15fa490d +0 -0
  89. package/.v8-cache/v24.7.0-x64-ef5a0af0/16335fd7 +0 -0
  90. package/.v8-cache/v24.7.0-x64-ef5a0af0/163becca +0 -0
  91. package/.v8-cache/v24.7.0-x64-ef5a0af0/164e3e5e +0 -0
  92. package/.v8-cache/v24.7.0-x64-ef5a0af0/16b272b6 +0 -0
  93. package/.v8-cache/v24.7.0-x64-ef5a0af0/170839c6 +0 -0
  94. package/.v8-cache/v24.7.0-x64-ef5a0af0/179d2560 +0 -0
  95. package/.v8-cache/v24.7.0-x64-ef5a0af0/18b392e3 +0 -0
  96. package/.v8-cache/v24.7.0-x64-ef5a0af0/18b9b488 +0 -0
  97. package/.v8-cache/v24.7.0-x64-ef5a0af0/19159518 +0 -0
  98. package/.v8-cache/v24.7.0-x64-ef5a0af0/1952de1c +0 -0
  99. package/.v8-cache/v24.7.0-x64-ef5a0af0/1984fc07 +0 -0
  100. package/.v8-cache/v24.7.0-x64-ef5a0af0/19f197ad +0 -0
  101. package/.v8-cache/v24.7.0-x64-ef5a0af0/1a5e8e8d +0 -0
  102. package/.v8-cache/v24.7.0-x64-ef5a0af0/1a706b3a +0 -0
  103. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ac56db9 +0 -0
  104. package/.v8-cache/v24.7.0-x64-ef5a0af0/1adc81af +0 -0
  105. package/.v8-cache/v24.7.0-x64-ef5a0af0/1b93bf09 +0 -0
  106. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ba48359 +0 -0
  107. package/.v8-cache/v24.7.0-x64-ef5a0af0/1bb5754d +0 -0
  108. package/.v8-cache/v24.7.0-x64-ef5a0af0/1be2b9da +0 -0
  109. package/.v8-cache/v24.7.0-x64-ef5a0af0/1be7684f +0 -0
  110. package/.v8-cache/v24.7.0-x64-ef5a0af0/1bfd6921 +0 -0
  111. package/.v8-cache/v24.7.0-x64-ef5a0af0/1bffe019 +0 -0
  112. package/.v8-cache/v24.7.0-x64-ef5a0af0/1c469ae5 +0 -0
  113. package/.v8-cache/v24.7.0-x64-ef5a0af0/1c475633 +0 -0
  114. package/.v8-cache/v24.7.0-x64-ef5a0af0/1c5927f8 +0 -0
  115. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ce66f73 +0 -0
  116. package/.v8-cache/v24.7.0-x64-ef5a0af0/1cf4fa03 +0 -0
  117. package/.v8-cache/v24.7.0-x64-ef5a0af0/1d25c7c3 +0 -0
  118. package/.v8-cache/v24.7.0-x64-ef5a0af0/1d5c9fc3 +0 -0
  119. package/.v8-cache/v24.7.0-x64-ef5a0af0/1d663bac +0 -0
  120. package/.v8-cache/v24.7.0-x64-ef5a0af0/1e01f894 +0 -0
  121. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ed1c91a +0 -0
  122. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ee1f213 +0 -0
  123. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ee5b179 +0 -0
  124. package/.v8-cache/v24.7.0-x64-ef5a0af0/1f18235c +0 -0
  125. package/.v8-cache/v24.7.0-x64-ef5a0af0/1f5d4d6e +0 -0
  126. package/.v8-cache/v24.7.0-x64-ef5a0af0/1f652552 +0 -0
  127. package/.v8-cache/v24.7.0-x64-ef5a0af0/1f73dfa6 +0 -0
  128. package/.v8-cache/v24.7.0-x64-ef5a0af0/1fb8f4f3 +0 -0
  129. package/.v8-cache/v24.7.0-x64-ef5a0af0/1fc63101 +0 -0
  130. package/.v8-cache/v24.7.0-x64-ef5a0af0/1fe241a5 +0 -0
  131. package/.v8-cache/v24.7.0-x64-ef5a0af0/1ff009c0 +0 -0
  132. package/.v8-cache/v24.7.0-x64-ef5a0af0/200bac84 +0 -0
  133. package/.v8-cache/v24.7.0-x64-ef5a0af0/205c8d02 +0 -0
  134. package/.v8-cache/v24.7.0-x64-ef5a0af0/20729831 +0 -0
  135. package/.v8-cache/v24.7.0-x64-ef5a0af0/2131725a +0 -0
  136. package/.v8-cache/v24.7.0-x64-ef5a0af0/214a593b +0 -0
  137. package/.v8-cache/v24.7.0-x64-ef5a0af0/21d5cee9 +0 -0
  138. package/.v8-cache/v24.7.0-x64-ef5a0af0/2202150b +0 -0
  139. package/.v8-cache/v24.7.0-x64-ef5a0af0/220e7b56 +0 -0
  140. package/.v8-cache/v24.7.0-x64-ef5a0af0/2227a346 +0 -0
  141. package/.v8-cache/v24.7.0-x64-ef5a0af0/222d1c3b +0 -0
  142. package/.v8-cache/v24.7.0-x64-ef5a0af0/22449bdf +0 -0
  143. package/.v8-cache/v24.7.0-x64-ef5a0af0/225be800 +0 -0
  144. package/.v8-cache/v24.7.0-x64-ef5a0af0/226e2801 +0 -0
  145. package/.v8-cache/v24.7.0-x64-ef5a0af0/2279b968 +0 -0
  146. package/.v8-cache/v24.7.0-x64-ef5a0af0/22a11d19 +0 -0
  147. package/.v8-cache/v24.7.0-x64-ef5a0af0/22b26067 +0 -0
  148. package/.v8-cache/v24.7.0-x64-ef5a0af0/22d1fe93 +0 -0
  149. package/.v8-cache/v24.7.0-x64-ef5a0af0/22d2135e +0 -0
  150. package/.v8-cache/v24.7.0-x64-ef5a0af0/2346b12a +0 -0
  151. package/.v8-cache/v24.7.0-x64-ef5a0af0/235d70e1 +0 -0
  152. package/.v8-cache/v24.7.0-x64-ef5a0af0/23be0144 +0 -0
  153. package/.v8-cache/v24.7.0-x64-ef5a0af0/23fa616f +0 -0
  154. package/.v8-cache/v24.7.0-x64-ef5a0af0/23fba0a5 +0 -0
  155. package/.v8-cache/v24.7.0-x64-ef5a0af0/24011fb1 +0 -0
  156. package/.v8-cache/v24.7.0-x64-ef5a0af0/2434bc16 +0 -0
  157. package/.v8-cache/v24.7.0-x64-ef5a0af0/24827a8b +0 -0
  158. package/.v8-cache/v24.7.0-x64-ef5a0af0/248ec463 +0 -0
  159. package/.v8-cache/v24.7.0-x64-ef5a0af0/24992b98 +0 -0
  160. package/.v8-cache/v24.7.0-x64-ef5a0af0/253ca67b +0 -0
  161. package/.v8-cache/v24.7.0-x64-ef5a0af0/25956228 +0 -0
  162. package/.v8-cache/v24.7.0-x64-ef5a0af0/25f8b84a +0 -0
  163. package/.v8-cache/v24.7.0-x64-ef5a0af0/2671108a +0 -0
  164. package/.v8-cache/v24.7.0-x64-ef5a0af0/26f5e7e4 +0 -0
  165. package/.v8-cache/v24.7.0-x64-ef5a0af0/274aed80 +0 -0
  166. package/.v8-cache/v24.7.0-x64-ef5a0af0/27518289 +0 -0
  167. package/.v8-cache/v24.7.0-x64-ef5a0af0/27f2aa55 +0 -0
  168. package/.v8-cache/v24.7.0-x64-ef5a0af0/282982b9 +0 -0
  169. package/.v8-cache/v24.7.0-x64-ef5a0af0/2888347a +0 -0
  170. package/.v8-cache/v24.7.0-x64-ef5a0af0/288b64fa +0 -0
  171. package/.v8-cache/v24.7.0-x64-ef5a0af0/2898560b +0 -0
  172. package/.v8-cache/v24.7.0-x64-ef5a0af0/28a61c69 +0 -0
  173. package/.v8-cache/v24.7.0-x64-ef5a0af0/28ffbc1d +0 -0
  174. package/.v8-cache/v24.7.0-x64-ef5a0af0/292ec490 +0 -0
  175. package/.v8-cache/v24.7.0-x64-ef5a0af0/294ed662 +0 -0
  176. package/.v8-cache/v24.7.0-x64-ef5a0af0/298ea736 +0 -0
  177. package/.v8-cache/v24.7.0-x64-ef5a0af0/2a3bcc77 +0 -0
  178. package/.v8-cache/v24.7.0-x64-ef5a0af0/2a59bb66 +0 -0
  179. package/.v8-cache/v24.7.0-x64-ef5a0af0/2a6ea0d3 +0 -0
  180. package/.v8-cache/v24.7.0-x64-ef5a0af0/2ae13c45 +0 -0
  181. package/.v8-cache/v24.7.0-x64-ef5a0af0/2b009cbc +0 -0
  182. package/.v8-cache/v24.7.0-x64-ef5a0af0/2b0e69c4 +0 -0
  183. package/.v8-cache/v24.7.0-x64-ef5a0af0/2b0f4b6b +0 -0
  184. package/.v8-cache/v24.7.0-x64-ef5a0af0/2c4092c9 +0 -0
  185. package/.v8-cache/v24.7.0-x64-ef5a0af0/2c9c08f1 +0 -0
  186. package/.v8-cache/v24.7.0-x64-ef5a0af0/2cfb63da +0 -0
  187. package/.v8-cache/v24.7.0-x64-ef5a0af0/2d3d90e6 +0 -0
  188. package/.v8-cache/v24.7.0-x64-ef5a0af0/2ddf9b3d +0 -0
  189. package/.v8-cache/v24.7.0-x64-ef5a0af0/2dfef59f +0 -0
  190. package/.v8-cache/v24.7.0-x64-ef5a0af0/2e0a55d8 +0 -0
  191. package/.v8-cache/v24.7.0-x64-ef5a0af0/2e1122c4 +0 -0
  192. package/.v8-cache/v24.7.0-x64-ef5a0af0/2edd52db +0 -0
  193. package/.v8-cache/v24.7.0-x64-ef5a0af0/2ee0e535 +0 -0
  194. package/.v8-cache/v24.7.0-x64-ef5a0af0/2efdc5f1 +0 -0
  195. package/.v8-cache/v24.7.0-x64-ef5a0af0/2f6a71e9 +0 -0
  196. package/.v8-cache/v24.7.0-x64-ef5a0af0/2fd39c60 +0 -0
  197. package/.v8-cache/v24.7.0-x64-ef5a0af0/3080203a +0 -0
  198. package/.v8-cache/v24.7.0-x64-ef5a0af0/30defcc4 +0 -0
  199. package/.v8-cache/v24.7.0-x64-ef5a0af0/310cc71e +0 -0
  200. package/.v8-cache/v24.7.0-x64-ef5a0af0/317ae0d4 +0 -0
  201. package/.v8-cache/v24.7.0-x64-ef5a0af0/31a335e9 +0 -0
  202. package/.v8-cache/v24.7.0-x64-ef5a0af0/320dd8dd +0 -0
  203. package/.v8-cache/v24.7.0-x64-ef5a0af0/3252896c +0 -0
  204. package/.v8-cache/v24.7.0-x64-ef5a0af0/327c1c07 +0 -0
  205. package/.v8-cache/v24.7.0-x64-ef5a0af0/328c6279 +0 -0
  206. package/.v8-cache/v24.7.0-x64-ef5a0af0/3294059a +0 -0
  207. package/.v8-cache/v24.7.0-x64-ef5a0af0/32e3b62d +0 -0
  208. package/.v8-cache/v24.7.0-x64-ef5a0af0/330ef2d9 +0 -0
  209. package/.v8-cache/v24.7.0-x64-ef5a0af0/33219a1d +0 -0
  210. package/.v8-cache/v24.7.0-x64-ef5a0af0/3348e276 +0 -0
  211. package/.v8-cache/v24.7.0-x64-ef5a0af0/336576f5 +0 -0
  212. package/.v8-cache/v24.7.0-x64-ef5a0af0/33764eac +0 -0
  213. package/.v8-cache/v24.7.0-x64-ef5a0af0/33c51e20 +0 -0
  214. package/.v8-cache/v24.7.0-x64-ef5a0af0/340f9315 +0 -0
  215. package/.v8-cache/v24.7.0-x64-ef5a0af0/342c77d2 +0 -0
  216. package/.v8-cache/v24.7.0-x64-ef5a0af0/343e81c6 +0 -0
  217. package/.v8-cache/v24.7.0-x64-ef5a0af0/347b6177 +0 -0
  218. package/.v8-cache/v24.7.0-x64-ef5a0af0/34cb7184 +0 -0
  219. package/.v8-cache/v24.7.0-x64-ef5a0af0/356622b9 +0 -0
  220. package/.v8-cache/v24.7.0-x64-ef5a0af0/35fef963 +0 -0
  221. package/.v8-cache/v24.7.0-x64-ef5a0af0/3603e10e +0 -0
  222. package/.v8-cache/v24.7.0-x64-ef5a0af0/36221a66 +0 -0
  223. package/.v8-cache/v24.7.0-x64-ef5a0af0/3628c445 +0 -0
  224. package/.v8-cache/v24.7.0-x64-ef5a0af0/369baa21 +0 -0
  225. package/.v8-cache/v24.7.0-x64-ef5a0af0/36ae29db +0 -0
  226. package/.v8-cache/v24.7.0-x64-ef5a0af0/37ff16b8 +0 -0
  227. package/.v8-cache/v24.7.0-x64-ef5a0af0/3820c8c0 +0 -0
  228. package/.v8-cache/v24.7.0-x64-ef5a0af0/385f17f0 +0 -0
  229. package/.v8-cache/v24.7.0-x64-ef5a0af0/387fb0ff +0 -0
  230. package/.v8-cache/v24.7.0-x64-ef5a0af0/3889e187 +0 -0
  231. package/.v8-cache/v24.7.0-x64-ef5a0af0/38e9bdfd +0 -0
  232. package/.v8-cache/v24.7.0-x64-ef5a0af0/38fc941f +0 -0
  233. package/.v8-cache/v24.7.0-x64-ef5a0af0/390eba92 +0 -0
  234. package/.v8-cache/v24.7.0-x64-ef5a0af0/3929c3fd +0 -0
  235. package/.v8-cache/v24.7.0-x64-ef5a0af0/394a60fb +0 -0
  236. package/.v8-cache/v24.7.0-x64-ef5a0af0/396e95f5 +0 -0
  237. package/.v8-cache/v24.7.0-x64-ef5a0af0/39714119 +0 -0
  238. package/.v8-cache/v24.7.0-x64-ef5a0af0/397aa701 +0 -0
  239. package/.v8-cache/v24.7.0-x64-ef5a0af0/39932d86 +0 -0
  240. package/.v8-cache/v24.7.0-x64-ef5a0af0/39f6ef83 +0 -0
  241. package/.v8-cache/v24.7.0-x64-ef5a0af0/3a0d2d35 +0 -0
  242. package/.v8-cache/v24.7.0-x64-ef5a0af0/3a8a01a8 +0 -0
  243. package/.v8-cache/v24.7.0-x64-ef5a0af0/3a9d8b43 +0 -0
  244. package/.v8-cache/v24.7.0-x64-ef5a0af0/3aef3075 +0 -0
  245. package/.v8-cache/v24.7.0-x64-ef5a0af0/3b1cee61 +0 -0
  246. package/.v8-cache/v24.7.0-x64-ef5a0af0/3b261113 +0 -0
  247. package/.v8-cache/v24.7.0-x64-ef5a0af0/3b489018 +0 -0
  248. package/.v8-cache/v24.7.0-x64-ef5a0af0/3bb077a9 +0 -0
  249. package/.v8-cache/v24.7.0-x64-ef5a0af0/3d0f0362 +0 -0
  250. package/.v8-cache/v24.7.0-x64-ef5a0af0/3d34684b +0 -0
  251. package/.v8-cache/v24.7.0-x64-ef5a0af0/3d8e182d +0 -0
  252. package/.v8-cache/v24.7.0-x64-ef5a0af0/3dded4fe +0 -0
  253. package/.v8-cache/v24.7.0-x64-ef5a0af0/3df413b6 +0 -0
  254. package/.v8-cache/v24.7.0-x64-ef5a0af0/3dfbce0f +0 -0
  255. package/.v8-cache/v24.7.0-x64-ef5a0af0/3e167233 +0 -0
  256. package/.v8-cache/v24.7.0-x64-ef5a0af0/3e51b96f +0 -0
  257. package/.v8-cache/v24.7.0-x64-ef5a0af0/3f0830f9 +0 -0
  258. package/.v8-cache/v24.7.0-x64-ef5a0af0/3f144a4d +0 -0
  259. package/.v8-cache/v24.7.0-x64-ef5a0af0/3f4a10a4 +0 -0
  260. package/.v8-cache/v24.7.0-x64-ef5a0af0/3f71ab30 +0 -0
  261. package/.v8-cache/v24.7.0-x64-ef5a0af0/3f72a97c +0 -0
  262. package/.v8-cache/v24.7.0-x64-ef5a0af0/3fb24e11 +0 -0
  263. package/.v8-cache/v24.7.0-x64-ef5a0af0/3fb42a37 +0 -0
  264. package/.v8-cache/v24.7.0-x64-ef5a0af0/3ff5494a +0 -0
  265. package/.v8-cache/v24.7.0-x64-ef5a0af0/40280e60 +0 -0
  266. package/.v8-cache/v24.7.0-x64-ef5a0af0/402b9ced +0 -0
  267. package/.v8-cache/v24.7.0-x64-ef5a0af0/402d22e1 +0 -0
  268. package/.v8-cache/v24.7.0-x64-ef5a0af0/409c7c13 +0 -0
  269. package/.v8-cache/v24.7.0-x64-ef5a0af0/416cff63 +0 -0
  270. package/.v8-cache/v24.7.0-x64-ef5a0af0/418c6632 +0 -0
  271. package/.v8-cache/v24.7.0-x64-ef5a0af0/4217fe8d +0 -0
  272. package/.v8-cache/v24.7.0-x64-ef5a0af0/42686149 +0 -0
  273. package/.v8-cache/v24.7.0-x64-ef5a0af0/42b4cd6e +0 -0
  274. package/.v8-cache/v24.7.0-x64-ef5a0af0/42d38f49 +0 -0
  275. package/.v8-cache/v24.7.0-x64-ef5a0af0/42e206b2 +0 -0
  276. package/.v8-cache/v24.7.0-x64-ef5a0af0/42ea4611 +0 -0
  277. package/.v8-cache/v24.7.0-x64-ef5a0af0/4352d5f1 +0 -0
  278. package/.v8-cache/v24.7.0-x64-ef5a0af0/43741164 +0 -0
  279. package/.v8-cache/v24.7.0-x64-ef5a0af0/43964317 +0 -0
  280. package/.v8-cache/v24.7.0-x64-ef5a0af0/43a02dbe +0 -0
  281. package/.v8-cache/v24.7.0-x64-ef5a0af0/441aa218 +0 -0
  282. package/.v8-cache/v24.7.0-x64-ef5a0af0/4444f4a5 +0 -0
  283. package/.v8-cache/v24.7.0-x64-ef5a0af0/4446168f +0 -0
  284. package/.v8-cache/v24.7.0-x64-ef5a0af0/44795769 +0 -0
  285. package/.v8-cache/v24.7.0-x64-ef5a0af0/4511bacf +0 -0
  286. package/.v8-cache/v24.7.0-x64-ef5a0af0/4579f46b +0 -0
  287. package/.v8-cache/v24.7.0-x64-ef5a0af0/45c0b437 +0 -0
  288. package/.v8-cache/v24.7.0-x64-ef5a0af0/45e61dc2 +0 -0
  289. package/.v8-cache/v24.7.0-x64-ef5a0af0/45fa217d +0 -0
  290. package/.v8-cache/v24.7.0-x64-ef5a0af0/4638c1db +0 -0
  291. package/.v8-cache/v24.7.0-x64-ef5a0af0/46b235d2 +0 -0
  292. package/.v8-cache/v24.7.0-x64-ef5a0af0/46b5351a +0 -0
  293. package/.v8-cache/v24.7.0-x64-ef5a0af0/46d1f5b9 +0 -0
  294. package/.v8-cache/v24.7.0-x64-ef5a0af0/4710b21d +0 -0
  295. package/.v8-cache/v24.7.0-x64-ef5a0af0/474c8493 +0 -0
  296. package/.v8-cache/v24.7.0-x64-ef5a0af0/476a98c7 +0 -0
  297. package/.v8-cache/v24.7.0-x64-ef5a0af0/478b0f9e +0 -0
  298. package/.v8-cache/v24.7.0-x64-ef5a0af0/47a248f8 +0 -0
  299. package/.v8-cache/v24.7.0-x64-ef5a0af0/490172a9 +0 -0
  300. package/.v8-cache/v24.7.0-x64-ef5a0af0/49811c20 +0 -0
  301. package/.v8-cache/v24.7.0-x64-ef5a0af0/4995c0b1 +0 -0
  302. package/.v8-cache/v24.7.0-x64-ef5a0af0/49ff164c +0 -0
  303. package/.v8-cache/v24.7.0-x64-ef5a0af0/4a183420 +0 -0
  304. package/.v8-cache/v24.7.0-x64-ef5a0af0/4a6b5991 +0 -0
  305. package/.v8-cache/v24.7.0-x64-ef5a0af0/4ab6ee9c +0 -0
  306. package/.v8-cache/v24.7.0-x64-ef5a0af0/4ab9082a +0 -0
  307. package/.v8-cache/v24.7.0-x64-ef5a0af0/4ace1785 +0 -0
  308. package/.v8-cache/v24.7.0-x64-ef5a0af0/4aed9772 +0 -0
  309. package/.v8-cache/v24.7.0-x64-ef5a0af0/4b356f9b +0 -0
  310. package/.v8-cache/v24.7.0-x64-ef5a0af0/4b3da816 +0 -0
  311. package/.v8-cache/v24.7.0-x64-ef5a0af0/4bc94a4f +0 -0
  312. package/.v8-cache/v24.7.0-x64-ef5a0af0/4c1d2edf +0 -0
  313. package/.v8-cache/v24.7.0-x64-ef5a0af0/4c36fd1a +0 -0
  314. package/.v8-cache/v24.7.0-x64-ef5a0af0/4cb12d26 +0 -0
  315. package/.v8-cache/v24.7.0-x64-ef5a0af0/4d365bf4 +0 -0
  316. package/.v8-cache/v24.7.0-x64-ef5a0af0/4d38a327 +0 -0
  317. package/.v8-cache/v24.7.0-x64-ef5a0af0/4d495a5d +0 -0
  318. package/.v8-cache/v24.7.0-x64-ef5a0af0/4d5d3951 +0 -0
  319. package/.v8-cache/v24.7.0-x64-ef5a0af0/4d730019 +0 -0
  320. package/.v8-cache/v24.7.0-x64-ef5a0af0/4dbb7a18 +0 -0
  321. package/.v8-cache/v24.7.0-x64-ef5a0af0/4dca171b +0 -0
  322. package/.v8-cache/v24.7.0-x64-ef5a0af0/4ea08a3f +0 -0
  323. package/.v8-cache/v24.7.0-x64-ef5a0af0/4ef2a13d +0 -0
  324. package/.v8-cache/v24.7.0-x64-ef5a0af0/4f076d8f +0 -0
  325. package/.v8-cache/v24.7.0-x64-ef5a0af0/4f5702bd +0 -0
  326. package/.v8-cache/v24.7.0-x64-ef5a0af0/4feb5610 +0 -0
  327. package/.v8-cache/v24.7.0-x64-ef5a0af0/4ff3b2bd +0 -0
  328. package/.v8-cache/v24.7.0-x64-ef5a0af0/506bbc76 +0 -0
  329. package/.v8-cache/v24.7.0-x64-ef5a0af0/50ad7efb +0 -0
  330. package/.v8-cache/v24.7.0-x64-ef5a0af0/50b2f904 +0 -0
  331. package/.v8-cache/v24.7.0-x64-ef5a0af0/512a6da0 +0 -0
  332. package/.v8-cache/v24.7.0-x64-ef5a0af0/514cc428 +0 -0
  333. package/.v8-cache/v24.7.0-x64-ef5a0af0/51a39ff2 +0 -0
  334. package/.v8-cache/v24.7.0-x64-ef5a0af0/51cc2102 +0 -0
  335. package/.v8-cache/v24.7.0-x64-ef5a0af0/5210925e +0 -0
  336. package/.v8-cache/v24.7.0-x64-ef5a0af0/523d6845 +0 -0
  337. package/.v8-cache/v24.7.0-x64-ef5a0af0/528e7353 +0 -0
  338. package/.v8-cache/v24.7.0-x64-ef5a0af0/532d1925 +0 -0
  339. package/.v8-cache/v24.7.0-x64-ef5a0af0/533f1f72 +0 -0
  340. package/.v8-cache/v24.7.0-x64-ef5a0af0/535532ea +0 -0
  341. package/.v8-cache/v24.7.0-x64-ef5a0af0/537a1162 +0 -0
  342. package/.v8-cache/v24.7.0-x64-ef5a0af0/53ecf786 +0 -0
  343. package/.v8-cache/v24.7.0-x64-ef5a0af0/541bd36a +0 -0
  344. package/.v8-cache/v24.7.0-x64-ef5a0af0/5428aebe +0 -0
  345. package/.v8-cache/v24.7.0-x64-ef5a0af0/543b651d +0 -0
  346. package/.v8-cache/v24.7.0-x64-ef5a0af0/54727607 +0 -0
  347. package/.v8-cache/v24.7.0-x64-ef5a0af0/5474dcc7 +0 -0
  348. package/.v8-cache/v24.7.0-x64-ef5a0af0/5478a1e3 +0 -0
  349. package/.v8-cache/v24.7.0-x64-ef5a0af0/54ce9568 +0 -0
  350. package/.v8-cache/v24.7.0-x64-ef5a0af0/54eff61e +0 -0
  351. package/.v8-cache/v24.7.0-x64-ef5a0af0/55100888 +0 -0
  352. package/.v8-cache/v24.7.0-x64-ef5a0af0/55197fc5 +0 -0
  353. package/.v8-cache/v24.7.0-x64-ef5a0af0/553b7af3 +0 -0
  354. package/.v8-cache/v24.7.0-x64-ef5a0af0/5558b83f +0 -0
  355. package/.v8-cache/v24.7.0-x64-ef5a0af0/55cba4b4 +0 -0
  356. package/.v8-cache/v24.7.0-x64-ef5a0af0/55e129df +0 -0
  357. package/.v8-cache/v24.7.0-x64-ef5a0af0/56292b7c +0 -0
  358. package/.v8-cache/v24.7.0-x64-ef5a0af0/5651a404 +0 -0
  359. package/.v8-cache/v24.7.0-x64-ef5a0af0/56752bb0 +0 -0
  360. package/.v8-cache/v24.7.0-x64-ef5a0af0/56a9a2bb +0 -0
  361. package/.v8-cache/v24.7.0-x64-ef5a0af0/56ef5751 +0 -0
  362. package/.v8-cache/v24.7.0-x64-ef5a0af0/57265523 +0 -0
  363. package/.v8-cache/v24.7.0-x64-ef5a0af0/582906d3 +0 -0
  364. package/.v8-cache/v24.7.0-x64-ef5a0af0/5851fcad +0 -0
  365. package/.v8-cache/v24.7.0-x64-ef5a0af0/590c3151 +0 -0
  366. package/.v8-cache/v24.7.0-x64-ef5a0af0/59223d85 +0 -0
  367. package/.v8-cache/v24.7.0-x64-ef5a0af0/5963f626 +0 -0
  368. package/.v8-cache/v24.7.0-x64-ef5a0af0/597241c0 +0 -0
  369. package/.v8-cache/v24.7.0-x64-ef5a0af0/5984469f +0 -0
  370. package/.v8-cache/v24.7.0-x64-ef5a0af0/59a01bfc +0 -0
  371. package/.v8-cache/v24.7.0-x64-ef5a0af0/59dade53 +0 -0
  372. package/.v8-cache/v24.7.0-x64-ef5a0af0/59f42f8b +0 -0
  373. package/.v8-cache/v24.7.0-x64-ef5a0af0/5a249081 +0 -0
  374. package/.v8-cache/v24.7.0-x64-ef5a0af0/5a94b2d4 +0 -0
  375. package/.v8-cache/v24.7.0-x64-ef5a0af0/5aa233d1 +0 -0
  376. package/.v8-cache/v24.7.0-x64-ef5a0af0/5b058fc0 +0 -0
  377. package/.v8-cache/v24.7.0-x64-ef5a0af0/5b1bb164 +0 -0
  378. package/.v8-cache/v24.7.0-x64-ef5a0af0/5b9982e1 +0 -0
  379. package/.v8-cache/v24.7.0-x64-ef5a0af0/5bf4c612 +0 -0
  380. package/.v8-cache/v24.7.0-x64-ef5a0af0/5c067259 +0 -0
  381. package/.v8-cache/v24.7.0-x64-ef5a0af0/5c58cf52 +0 -0
  382. package/.v8-cache/v24.7.0-x64-ef5a0af0/5c860b06 +0 -0
  383. package/.v8-cache/v24.7.0-x64-ef5a0af0/5cc2a5f2 +0 -0
  384. package/.v8-cache/v24.7.0-x64-ef5a0af0/5d4c732f +0 -0
  385. package/.v8-cache/v24.7.0-x64-ef5a0af0/5db76f6b +0 -0
  386. package/.v8-cache/v24.7.0-x64-ef5a0af0/5dc5697b +0 -0
  387. package/.v8-cache/v24.7.0-x64-ef5a0af0/5dd238c0 +0 -0
  388. package/.v8-cache/v24.7.0-x64-ef5a0af0/5de311f1 +0 -0
  389. package/.v8-cache/v24.7.0-x64-ef5a0af0/5e0ed80f +0 -0
  390. package/.v8-cache/v24.7.0-x64-ef5a0af0/5e44306a +0 -0
  391. package/.v8-cache/v24.7.0-x64-ef5a0af0/5e7d0d5d +0 -0
  392. package/.v8-cache/v24.7.0-x64-ef5a0af0/5ed2b572 +0 -0
  393. package/.v8-cache/v24.7.0-x64-ef5a0af0/5ed7f7db +0 -0
  394. package/.v8-cache/v24.7.0-x64-ef5a0af0/5ef33731 +0 -0
  395. package/.v8-cache/v24.7.0-x64-ef5a0af0/5ef36bb9 +0 -0
  396. package/.v8-cache/v24.7.0-x64-ef5a0af0/5f7e2d51 +0 -0
  397. package/.v8-cache/v24.7.0-x64-ef5a0af0/5f8deeb1 +0 -0
  398. package/.v8-cache/v24.7.0-x64-ef5a0af0/6003d22a +0 -0
  399. package/.v8-cache/v24.7.0-x64-ef5a0af0/603d1a09 +0 -0
  400. package/.v8-cache/v24.7.0-x64-ef5a0af0/605e6a0a +0 -0
  401. package/.v8-cache/v24.7.0-x64-ef5a0af0/60c098f5 +0 -0
  402. package/.v8-cache/v24.7.0-x64-ef5a0af0/6176a9b5 +0 -0
  403. package/.v8-cache/v24.7.0-x64-ef5a0af0/6196810e +0 -0
  404. package/.v8-cache/v24.7.0-x64-ef5a0af0/61a71c97 +0 -0
  405. package/.v8-cache/v24.7.0-x64-ef5a0af0/61eaf84a +0 -0
  406. package/.v8-cache/v24.7.0-x64-ef5a0af0/61f1d3fb +0 -0
  407. package/.v8-cache/v24.7.0-x64-ef5a0af0/61f394a9 +0 -0
  408. package/.v8-cache/v24.7.0-x64-ef5a0af0/62d92c26 +0 -0
  409. package/.v8-cache/v24.7.0-x64-ef5a0af0/62dd6080 +0 -0
  410. package/.v8-cache/v24.7.0-x64-ef5a0af0/62eddf8a +0 -0
  411. package/.v8-cache/v24.7.0-x64-ef5a0af0/6444bdab +0 -0
  412. package/.v8-cache/v24.7.0-x64-ef5a0af0/64506dd0 +0 -0
  413. package/.v8-cache/v24.7.0-x64-ef5a0af0/647d847c +0 -0
  414. package/.v8-cache/v24.7.0-x64-ef5a0af0/6486c16e +0 -0
  415. package/.v8-cache/v24.7.0-x64-ef5a0af0/65566701 +0 -0
  416. package/.v8-cache/v24.7.0-x64-ef5a0af0/66b763a6 +0 -0
  417. package/.v8-cache/v24.7.0-x64-ef5a0af0/6727e91e +0 -0
  418. package/.v8-cache/v24.7.0-x64-ef5a0af0/677e9881 +0 -0
  419. package/.v8-cache/v24.7.0-x64-ef5a0af0/67d8a7e0 +0 -0
  420. package/.v8-cache/v24.7.0-x64-ef5a0af0/67ef7bde +0 -0
  421. package/.v8-cache/v24.7.0-x64-ef5a0af0/68416cb2 +0 -0
  422. package/.v8-cache/v24.7.0-x64-ef5a0af0/685371b6 +0 -0
  423. package/.v8-cache/v24.7.0-x64-ef5a0af0/68f5b890 +0 -0
  424. package/.v8-cache/v24.7.0-x64-ef5a0af0/69ad03b4 +0 -0
  425. package/.v8-cache/v24.7.0-x64-ef5a0af0/6a31058b +0 -0
  426. package/.v8-cache/v24.7.0-x64-ef5a0af0/6a4adaa4 +0 -0
  427. package/.v8-cache/v24.7.0-x64-ef5a0af0/6a73701d +0 -0
  428. package/.v8-cache/v24.7.0-x64-ef5a0af0/6ae637d3 +0 -0
  429. package/.v8-cache/v24.7.0-x64-ef5a0af0/6b22f01c +0 -0
  430. package/.v8-cache/v24.7.0-x64-ef5a0af0/6bebb7f2 +0 -0
  431. package/.v8-cache/v24.7.0-x64-ef5a0af0/6c0e40d0 +0 -0
  432. package/.v8-cache/v24.7.0-x64-ef5a0af0/6c2dc97b +0 -0
  433. package/.v8-cache/v24.7.0-x64-ef5a0af0/6c2fd108 +0 -0
  434. package/.v8-cache/v24.7.0-x64-ef5a0af0/6c8191df +0 -0
  435. package/.v8-cache/v24.7.0-x64-ef5a0af0/6c9900bc +0 -0
  436. package/.v8-cache/v24.7.0-x64-ef5a0af0/6d38b642 +0 -0
  437. package/.v8-cache/v24.7.0-x64-ef5a0af0/6d58e5bb +0 -0
  438. package/.v8-cache/v24.7.0-x64-ef5a0af0/6e946a0e +0 -0
  439. package/.v8-cache/v24.7.0-x64-ef5a0af0/6eb2502a +0 -0
  440. package/.v8-cache/v24.7.0-x64-ef5a0af0/6ee04204 +0 -0
  441. package/.v8-cache/v24.7.0-x64-ef5a0af0/6f521f56 +0 -0
  442. package/.v8-cache/v24.7.0-x64-ef5a0af0/6f74c50b +0 -0
  443. package/.v8-cache/v24.7.0-x64-ef5a0af0/701a046d +0 -0
  444. package/.v8-cache/v24.7.0-x64-ef5a0af0/70a89c43 +0 -0
  445. package/.v8-cache/v24.7.0-x64-ef5a0af0/70f983f3 +0 -0
  446. package/.v8-cache/v24.7.0-x64-ef5a0af0/711557af +0 -0
  447. package/.v8-cache/v24.7.0-x64-ef5a0af0/7116147f +0 -0
  448. package/.v8-cache/v24.7.0-x64-ef5a0af0/716d12a6 +0 -0
  449. package/.v8-cache/v24.7.0-x64-ef5a0af0/71df9cb3 +0 -0
  450. package/.v8-cache/v24.7.0-x64-ef5a0af0/71e82eb3 +0 -0
  451. package/.v8-cache/v24.7.0-x64-ef5a0af0/721bcb05 +0 -0
  452. package/.v8-cache/v24.7.0-x64-ef5a0af0/7242c21e +0 -0
  453. package/.v8-cache/v24.7.0-x64-ef5a0af0/728b0581 +0 -0
  454. package/.v8-cache/v24.7.0-x64-ef5a0af0/72c8965f +0 -0
  455. package/.v8-cache/v24.7.0-x64-ef5a0af0/72eec452 +0 -0
  456. package/.v8-cache/v24.7.0-x64-ef5a0af0/7313f723 +0 -0
  457. package/.v8-cache/v24.7.0-x64-ef5a0af0/73158906 +0 -0
  458. package/.v8-cache/v24.7.0-x64-ef5a0af0/73353274 +0 -0
  459. package/.v8-cache/v24.7.0-x64-ef5a0af0/733b4559 +0 -0
  460. package/.v8-cache/v24.7.0-x64-ef5a0af0/73c838ba +0 -0
  461. package/.v8-cache/v24.7.0-x64-ef5a0af0/73e0f4b3 +0 -0
  462. package/.v8-cache/v24.7.0-x64-ef5a0af0/73eb8d30 +0 -0
  463. package/.v8-cache/v24.7.0-x64-ef5a0af0/73fb952b +0 -0
  464. package/.v8-cache/v24.7.0-x64-ef5a0af0/7418e241 +0 -0
  465. package/.v8-cache/v24.7.0-x64-ef5a0af0/745708c8 +0 -0
  466. package/.v8-cache/v24.7.0-x64-ef5a0af0/7468f55c +0 -0
  467. package/.v8-cache/v24.7.0-x64-ef5a0af0/749cecdb +0 -0
  468. package/.v8-cache/v24.7.0-x64-ef5a0af0/74ba3a2a +0 -0
  469. package/.v8-cache/v24.7.0-x64-ef5a0af0/750e2446 +0 -0
  470. package/.v8-cache/v24.7.0-x64-ef5a0af0/7541c12c +0 -0
  471. package/.v8-cache/v24.7.0-x64-ef5a0af0/7543f690 +0 -0
  472. package/.v8-cache/v24.7.0-x64-ef5a0af0/75d38e6f +0 -0
  473. package/.v8-cache/v24.7.0-x64-ef5a0af0/75d8ff37 +0 -0
  474. package/.v8-cache/v24.7.0-x64-ef5a0af0/75efccd4 +0 -0
  475. package/.v8-cache/v24.7.0-x64-ef5a0af0/75f522a1 +0 -0
  476. package/.v8-cache/v24.7.0-x64-ef5a0af0/762f9305 +0 -0
  477. package/.v8-cache/v24.7.0-x64-ef5a0af0/767481d0 +0 -0
  478. package/.v8-cache/v24.7.0-x64-ef5a0af0/768ba9a5 +0 -0
  479. package/.v8-cache/v24.7.0-x64-ef5a0af0/7695e4ef +0 -0
  480. package/.v8-cache/v24.7.0-x64-ef5a0af0/76c7489f +0 -0
  481. package/.v8-cache/v24.7.0-x64-ef5a0af0/7715fc2c +0 -0
  482. package/.v8-cache/v24.7.0-x64-ef5a0af0/771e5d19 +0 -0
  483. package/.v8-cache/v24.7.0-x64-ef5a0af0/7783a8ec +0 -0
  484. package/.v8-cache/v24.7.0-x64-ef5a0af0/7794a6a9 +0 -0
  485. package/.v8-cache/v24.7.0-x64-ef5a0af0/77fc558f +0 -0
  486. package/.v8-cache/v24.7.0-x64-ef5a0af0/780a6805 +0 -0
  487. package/.v8-cache/v24.7.0-x64-ef5a0af0/781ef7b9 +0 -0
  488. package/.v8-cache/v24.7.0-x64-ef5a0af0/782e025a +0 -0
  489. package/.v8-cache/v24.7.0-x64-ef5a0af0/789dd9a4 +0 -0
  490. package/.v8-cache/v24.7.0-x64-ef5a0af0/79e9b74f +0 -0
  491. package/.v8-cache/v24.7.0-x64-ef5a0af0/79fbbd38 +0 -0
  492. package/.v8-cache/v24.7.0-x64-ef5a0af0/7a01d94e +0 -0
  493. package/.v8-cache/v24.7.0-x64-ef5a0af0/7a4e4f17 +0 -0
  494. package/.v8-cache/v24.7.0-x64-ef5a0af0/7a7e7427 +0 -0
  495. package/.v8-cache/v24.7.0-x64-ef5a0af0/7a8afdb8 +0 -0
  496. package/.v8-cache/v24.7.0-x64-ef5a0af0/7aa6ee01 +0 -0
  497. package/.v8-cache/v24.7.0-x64-ef5a0af0/7ae33d88 +0 -0
  498. package/.v8-cache/v24.7.0-x64-ef5a0af0/7b0590ed +0 -0
  499. package/.v8-cache/v24.7.0-x64-ef5a0af0/7bb47bcb +0 -0
  500. package/.v8-cache/v24.7.0-x64-ef5a0af0/7bcfc50a +0 -0
  501. package/.v8-cache/v24.7.0-x64-ef5a0af0/7bd03b5b +0 -0
  502. package/.v8-cache/v24.7.0-x64-ef5a0af0/7be39abc +0 -0
  503. package/.v8-cache/v24.7.0-x64-ef5a0af0/7c85800f +0 -0
  504. package/.v8-cache/v24.7.0-x64-ef5a0af0/7ca4a550 +0 -0
  505. package/.v8-cache/v24.7.0-x64-ef5a0af0/7d30017d +0 -0
  506. package/.v8-cache/v24.7.0-x64-ef5a0af0/7de2104f +0 -0
  507. package/.v8-cache/v24.7.0-x64-ef5a0af0/7de5f39a +0 -0
  508. package/.v8-cache/v24.7.0-x64-ef5a0af0/7df6f53b +0 -0
  509. package/.v8-cache/v24.7.0-x64-ef5a0af0/7e0c196c +0 -0
  510. package/.v8-cache/v24.7.0-x64-ef5a0af0/7e1d748b +0 -0
  511. package/.v8-cache/v24.7.0-x64-ef5a0af0/7e8b8aaf +0 -0
  512. package/.v8-cache/v24.7.0-x64-ef5a0af0/7ea06cea +0 -0
  513. package/.v8-cache/v24.7.0-x64-ef5a0af0/7f1a5577 +0 -0
  514. package/.v8-cache/v24.7.0-x64-ef5a0af0/7f33fee5 +0 -0
  515. package/.v8-cache/v24.7.0-x64-ef5a0af0/7f8ed7c6 +0 -0
  516. package/.v8-cache/v24.7.0-x64-ef5a0af0/7fe0e38a +0 -0
  517. package/.v8-cache/v24.7.0-x64-ef5a0af0/800e8a5f +0 -0
  518. package/.v8-cache/v24.7.0-x64-ef5a0af0/8078686f +0 -0
  519. package/.v8-cache/v24.7.0-x64-ef5a0af0/807976df +0 -0
  520. package/.v8-cache/v24.7.0-x64-ef5a0af0/80f57bae +0 -0
  521. package/.v8-cache/v24.7.0-x64-ef5a0af0/812b8370 +0 -0
  522. package/.v8-cache/v24.7.0-x64-ef5a0af0/813658cd +0 -0
  523. package/.v8-cache/v24.7.0-x64-ef5a0af0/81576ef6 +0 -0
  524. package/.v8-cache/v24.7.0-x64-ef5a0af0/817f3f23 +0 -0
  525. package/.v8-cache/v24.7.0-x64-ef5a0af0/81bc70ec +0 -0
  526. package/.v8-cache/v24.7.0-x64-ef5a0af0/81f899eb +0 -0
  527. package/.v8-cache/v24.7.0-x64-ef5a0af0/825e9a05 +0 -0
  528. package/.v8-cache/v24.7.0-x64-ef5a0af0/82884d2a +0 -0
  529. package/.v8-cache/v24.7.0-x64-ef5a0af0/82daf4d1 +0 -0
  530. package/.v8-cache/v24.7.0-x64-ef5a0af0/8405c894 +0 -0
  531. package/.v8-cache/v24.7.0-x64-ef5a0af0/84d05a23 +0 -0
  532. package/.v8-cache/v24.7.0-x64-ef5a0af0/85d87999 +0 -0
  533. package/.v8-cache/v24.7.0-x64-ef5a0af0/85ef818a +0 -0
  534. package/.v8-cache/v24.7.0-x64-ef5a0af0/863b37e7 +0 -0
  535. package/.v8-cache/v24.7.0-x64-ef5a0af0/86a117bb +0 -0
  536. package/.v8-cache/v24.7.0-x64-ef5a0af0/87372817 +0 -0
  537. package/.v8-cache/v24.7.0-x64-ef5a0af0/874b7136 +0 -0
  538. package/.v8-cache/v24.7.0-x64-ef5a0af0/877f8bab +0 -0
  539. package/.v8-cache/v24.7.0-x64-ef5a0af0/878008da +0 -0
  540. package/.v8-cache/v24.7.0-x64-ef5a0af0/87815309 +0 -0
  541. package/.v8-cache/v24.7.0-x64-ef5a0af0/87a30202 +0 -0
  542. package/.v8-cache/v24.7.0-x64-ef5a0af0/87cf2209 +0 -0
  543. package/.v8-cache/v24.7.0-x64-ef5a0af0/8862032d +0 -0
  544. package/.v8-cache/v24.7.0-x64-ef5a0af0/88f1dc55 +0 -0
  545. package/.v8-cache/v24.7.0-x64-ef5a0af0/8909e62b +0 -0
  546. package/.v8-cache/v24.7.0-x64-ef5a0af0/891a7c73 +0 -0
  547. package/.v8-cache/v24.7.0-x64-ef5a0af0/898c22f0 +0 -0
  548. package/.v8-cache/v24.7.0-x64-ef5a0af0/89d161f1 +0 -0
  549. package/.v8-cache/v24.7.0-x64-ef5a0af0/89de43e7 +0 -0
  550. package/.v8-cache/v24.7.0-x64-ef5a0af0/8a586ea8 +0 -0
  551. package/.v8-cache/v24.7.0-x64-ef5a0af0/8a5bb9fc +0 -0
  552. package/.v8-cache/v24.7.0-x64-ef5a0af0/8ac7c507 +0 -0
  553. package/.v8-cache/v24.7.0-x64-ef5a0af0/8b02de67 +0 -0
  554. package/.v8-cache/v24.7.0-x64-ef5a0af0/8b12d9e8 +0 -0
  555. package/.v8-cache/v24.7.0-x64-ef5a0af0/8b1b2594 +0 -0
  556. package/.v8-cache/v24.7.0-x64-ef5a0af0/8b68a3a2 +0 -0
  557. package/.v8-cache/v24.7.0-x64-ef5a0af0/8bc41a69 +0 -0
  558. package/.v8-cache/v24.7.0-x64-ef5a0af0/8c2e23c4 +0 -0
  559. package/.v8-cache/v24.7.0-x64-ef5a0af0/8c5d72ae +0 -0
  560. package/.v8-cache/v24.7.0-x64-ef5a0af0/8c62a113 +0 -0
  561. package/.v8-cache/v24.7.0-x64-ef5a0af0/8ccefbfd +0 -0
  562. package/.v8-cache/v24.7.0-x64-ef5a0af0/8cfb53c0 +0 -0
  563. package/.v8-cache/v24.7.0-x64-ef5a0af0/8d4e065b +0 -0
  564. package/.v8-cache/v24.7.0-x64-ef5a0af0/8d8378fb +0 -0
  565. package/.v8-cache/v24.7.0-x64-ef5a0af0/8dd99279 +0 -0
  566. package/.v8-cache/v24.7.0-x64-ef5a0af0/8deab10b +0 -0
  567. package/.v8-cache/v24.7.0-x64-ef5a0af0/8e3c6c89 +0 -0
  568. package/.v8-cache/v24.7.0-x64-ef5a0af0/8e623d0b +0 -0
  569. package/.v8-cache/v24.7.0-x64-ef5a0af0/8ee4e5aa +0 -0
  570. package/.v8-cache/v24.7.0-x64-ef5a0af0/8f19f1de +0 -0
  571. package/.v8-cache/v24.7.0-x64-ef5a0af0/8f2491c8 +0 -0
  572. package/.v8-cache/v24.7.0-x64-ef5a0af0/8f441a77 +0 -0
  573. package/.v8-cache/v24.7.0-x64-ef5a0af0/8f7edf28 +0 -0
  574. package/.v8-cache/v24.7.0-x64-ef5a0af0/8fc31d85 +0 -0
  575. package/.v8-cache/v24.7.0-x64-ef5a0af0/9000aef3 +0 -0
  576. package/.v8-cache/v24.7.0-x64-ef5a0af0/902c662a +0 -0
  577. package/.v8-cache/v24.7.0-x64-ef5a0af0/903a4bb6 +0 -0
  578. package/.v8-cache/v24.7.0-x64-ef5a0af0/90844771 +0 -0
  579. package/.v8-cache/v24.7.0-x64-ef5a0af0/90fca974 +0 -0
  580. package/.v8-cache/v24.7.0-x64-ef5a0af0/911342f2 +0 -0
  581. package/.v8-cache/v24.7.0-x64-ef5a0af0/9118f4fa +0 -0
  582. package/.v8-cache/v24.7.0-x64-ef5a0af0/9186e2f2 +0 -0
  583. package/.v8-cache/v24.7.0-x64-ef5a0af0/9193c92b +0 -0
  584. package/.v8-cache/v24.7.0-x64-ef5a0af0/91968dc1 +0 -0
  585. package/.v8-cache/v24.7.0-x64-ef5a0af0/91a0a363 +0 -0
  586. package/.v8-cache/v24.7.0-x64-ef5a0af0/91b97b47 +0 -0
  587. package/.v8-cache/v24.7.0-x64-ef5a0af0/91c7bbd0 +0 -0
  588. package/.v8-cache/v24.7.0-x64-ef5a0af0/91fe7831 +0 -0
  589. package/.v8-cache/v24.7.0-x64-ef5a0af0/922da448 +0 -0
  590. package/.v8-cache/v24.7.0-x64-ef5a0af0/92514b71 +0 -0
  591. package/.v8-cache/v24.7.0-x64-ef5a0af0/9257d0ef +0 -0
  592. package/.v8-cache/v24.7.0-x64-ef5a0af0/926b4568 +0 -0
  593. package/.v8-cache/v24.7.0-x64-ef5a0af0/92f65872 +0 -0
  594. package/.v8-cache/v24.7.0-x64-ef5a0af0/932f0770 +0 -0
  595. package/.v8-cache/v24.7.0-x64-ef5a0af0/9342cfc6 +0 -0
  596. package/.v8-cache/v24.7.0-x64-ef5a0af0/93d40c73 +0 -0
  597. package/.v8-cache/v24.7.0-x64-ef5a0af0/941ef74f +0 -0
  598. package/.v8-cache/v24.7.0-x64-ef5a0af0/94768b3a +0 -0
  599. package/.v8-cache/v24.7.0-x64-ef5a0af0/9496d8e2 +0 -0
  600. package/.v8-cache/v24.7.0-x64-ef5a0af0/95045a9e +0 -0
  601. package/.v8-cache/v24.7.0-x64-ef5a0af0/957fe9a8 +0 -0
  602. package/.v8-cache/v24.7.0-x64-ef5a0af0/95b0d444 +0 -0
  603. package/.v8-cache/v24.7.0-x64-ef5a0af0/96c57777 +0 -0
  604. package/.v8-cache/v24.7.0-x64-ef5a0af0/96c95ddb +0 -0
  605. package/.v8-cache/v24.7.0-x64-ef5a0af0/97725d49 +0 -0
  606. package/.v8-cache/v24.7.0-x64-ef5a0af0/9779e811 +0 -0
  607. package/.v8-cache/v24.7.0-x64-ef5a0af0/977ff23b +0 -0
  608. package/.v8-cache/v24.7.0-x64-ef5a0af0/97af179d +0 -0
  609. package/.v8-cache/v24.7.0-x64-ef5a0af0/984a30e9 +0 -0
  610. package/.v8-cache/v24.7.0-x64-ef5a0af0/9914411b +0 -0
  611. package/.v8-cache/v24.7.0-x64-ef5a0af0/9920378d +0 -0
  612. package/.v8-cache/v24.7.0-x64-ef5a0af0/99315032 +0 -0
  613. package/.v8-cache/v24.7.0-x64-ef5a0af0/995c817a +0 -0
  614. package/.v8-cache/v24.7.0-x64-ef5a0af0/99ae9d9d +0 -0
  615. package/.v8-cache/v24.7.0-x64-ef5a0af0/99c01743 +0 -0
  616. package/.v8-cache/v24.7.0-x64-ef5a0af0/99e350e4 +0 -0
  617. package/.v8-cache/v24.7.0-x64-ef5a0af0/9a7a57f4 +0 -0
  618. package/.v8-cache/v24.7.0-x64-ef5a0af0/9a820759 +0 -0
  619. package/.v8-cache/v24.7.0-x64-ef5a0af0/9a879959 +0 -0
  620. package/.v8-cache/v24.7.0-x64-ef5a0af0/9ae44aeb +0 -0
  621. package/.v8-cache/v24.7.0-x64-ef5a0af0/9b052f8a +0 -0
  622. package/.v8-cache/v24.7.0-x64-ef5a0af0/9b0b0a85 +0 -0
  623. package/.v8-cache/v24.7.0-x64-ef5a0af0/9b37b511 +0 -0
  624. package/.v8-cache/v24.7.0-x64-ef5a0af0/9b489257 +0 -0
  625. package/.v8-cache/v24.7.0-x64-ef5a0af0/9bb7b87b +0 -0
  626. package/.v8-cache/v24.7.0-x64-ef5a0af0/9bef6a06 +0 -0
  627. package/.v8-cache/v24.7.0-x64-ef5a0af0/9c516c0d +0 -0
  628. package/.v8-cache/v24.7.0-x64-ef5a0af0/9c57e9fb +0 -0
  629. package/.v8-cache/v24.7.0-x64-ef5a0af0/9c8e932f +0 -0
  630. package/.v8-cache/v24.7.0-x64-ef5a0af0/9d0fff67 +0 -0
  631. package/.v8-cache/v24.7.0-x64-ef5a0af0/9d4f46f1 +0 -0
  632. package/.v8-cache/v24.7.0-x64-ef5a0af0/9d5899b0 +0 -0
  633. package/.v8-cache/v24.7.0-x64-ef5a0af0/9de3f3ae +0 -0
  634. package/.v8-cache/v24.7.0-x64-ef5a0af0/9e44e752 +0 -0
  635. package/.v8-cache/v24.7.0-x64-ef5a0af0/9e71076a +0 -0
  636. package/.v8-cache/v24.7.0-x64-ef5a0af0/9ed80ba5 +0 -0
  637. package/.v8-cache/v24.7.0-x64-ef5a0af0/9f70617f +0 -0
  638. package/.v8-cache/v24.7.0-x64-ef5a0af0/9f92f695 +0 -0
  639. package/.v8-cache/v24.7.0-x64-ef5a0af0/9fb5e6d3 +0 -0
  640. package/.v8-cache/v24.7.0-x64-ef5a0af0/9fb85165 +0 -0
  641. package/.v8-cache/v24.7.0-x64-ef5a0af0/a01ad988 +0 -0
  642. package/.v8-cache/v24.7.0-x64-ef5a0af0/a04c762a +0 -0
  643. package/.v8-cache/v24.7.0-x64-ef5a0af0/a0c45d7e +0 -0
  644. package/.v8-cache/v24.7.0-x64-ef5a0af0/a0deb7e8 +0 -0
  645. package/.v8-cache/v24.7.0-x64-ef5a0af0/a0f03400 +0 -0
  646. package/.v8-cache/v24.7.0-x64-ef5a0af0/a1194e24 +0 -0
  647. package/.v8-cache/v24.7.0-x64-ef5a0af0/a1d12a93 +0 -0
  648. package/.v8-cache/v24.7.0-x64-ef5a0af0/a20cefa2 +0 -0
  649. package/.v8-cache/v24.7.0-x64-ef5a0af0/a20e8d0d +0 -0
  650. package/.v8-cache/v24.7.0-x64-ef5a0af0/a265672a +0 -0
  651. package/.v8-cache/v24.7.0-x64-ef5a0af0/a26ce9c9 +0 -0
  652. package/.v8-cache/v24.7.0-x64-ef5a0af0/a2b26ae5 +0 -0
  653. package/.v8-cache/v24.7.0-x64-ef5a0af0/a33e7cec +0 -0
  654. package/.v8-cache/v24.7.0-x64-ef5a0af0/a33fd10a +0 -0
  655. package/.v8-cache/v24.7.0-x64-ef5a0af0/a358bf76 +0 -0
  656. package/.v8-cache/v24.7.0-x64-ef5a0af0/a3863874 +0 -0
  657. package/.v8-cache/v24.7.0-x64-ef5a0af0/a3acec94 +0 -0
  658. package/.v8-cache/v24.7.0-x64-ef5a0af0/a4041f49 +0 -0
  659. package/.v8-cache/v24.7.0-x64-ef5a0af0/a4932241 +0 -0
  660. package/.v8-cache/v24.7.0-x64-ef5a0af0/a4be7766 +0 -0
  661. package/.v8-cache/v24.7.0-x64-ef5a0af0/a4f1e349 +0 -0
  662. package/.v8-cache/v24.7.0-x64-ef5a0af0/a4f97284 +0 -0
  663. package/.v8-cache/v24.7.0-x64-ef5a0af0/a55bff1b +0 -0
  664. package/.v8-cache/v24.7.0-x64-ef5a0af0/a59de33d +0 -0
  665. package/.v8-cache/v24.7.0-x64-ef5a0af0/a5f77833 +0 -0
  666. package/.v8-cache/v24.7.0-x64-ef5a0af0/a621f48c +0 -0
  667. package/.v8-cache/v24.7.0-x64-ef5a0af0/a6643a14 +0 -0
  668. package/.v8-cache/v24.7.0-x64-ef5a0af0/a6748667 +0 -0
  669. package/.v8-cache/v24.7.0-x64-ef5a0af0/a6c2c369 +0 -0
  670. package/.v8-cache/v24.7.0-x64-ef5a0af0/a741626b +0 -0
  671. package/.v8-cache/v24.7.0-x64-ef5a0af0/a7e80865 +0 -0
  672. package/.v8-cache/v24.7.0-x64-ef5a0af0/a8666b05 +0 -0
  673. package/.v8-cache/v24.7.0-x64-ef5a0af0/a86d680a +0 -0
  674. package/.v8-cache/v24.7.0-x64-ef5a0af0/a873c003 +0 -0
  675. package/.v8-cache/v24.7.0-x64-ef5a0af0/a8aab654 +0 -0
  676. package/.v8-cache/v24.7.0-x64-ef5a0af0/a8b283e0 +0 -0
  677. package/.v8-cache/v24.7.0-x64-ef5a0af0/a9054abf +0 -0
  678. package/.v8-cache/v24.7.0-x64-ef5a0af0/a960a675 +0 -0
  679. package/.v8-cache/v24.7.0-x64-ef5a0af0/aa55d7ae +0 -0
  680. package/.v8-cache/v24.7.0-x64-ef5a0af0/ab0dca28 +0 -0
  681. package/.v8-cache/v24.7.0-x64-ef5a0af0/ab69c9a1 +0 -0
  682. package/.v8-cache/v24.7.0-x64-ef5a0af0/ab904af9 +0 -0
  683. package/.v8-cache/v24.7.0-x64-ef5a0af0/ac185236 +0 -0
  684. package/.v8-cache/v24.7.0-x64-ef5a0af0/ac317c9c +0 -0
  685. package/.v8-cache/v24.7.0-x64-ef5a0af0/ac526d4e +0 -0
  686. package/.v8-cache/v24.7.0-x64-ef5a0af0/ac65aea2 +0 -0
  687. package/.v8-cache/v24.7.0-x64-ef5a0af0/acafde5a +0 -0
  688. package/.v8-cache/v24.7.0-x64-ef5a0af0/acc15438 +0 -0
  689. package/.v8-cache/v24.7.0-x64-ef5a0af0/acc36e66 +0 -0
  690. package/.v8-cache/v24.7.0-x64-ef5a0af0/ad02c34a +0 -0
  691. package/.v8-cache/v24.7.0-x64-ef5a0af0/ad168735 +0 -0
  692. package/.v8-cache/v24.7.0-x64-ef5a0af0/ad92ba0e +0 -0
  693. package/.v8-cache/v24.7.0-x64-ef5a0af0/adbb59d4 +0 -0
  694. package/.v8-cache/v24.7.0-x64-ef5a0af0/adc2dadb +0 -0
  695. package/.v8-cache/v24.7.0-x64-ef5a0af0/add82f56 +0 -0
  696. package/.v8-cache/v24.7.0-x64-ef5a0af0/ae5b14c8 +0 -0
  697. package/.v8-cache/v24.7.0-x64-ef5a0af0/ae77d203 +0 -0
  698. package/.v8-cache/v24.7.0-x64-ef5a0af0/aebb23ca +0 -0
  699. package/.v8-cache/v24.7.0-x64-ef5a0af0/af467df1 +0 -0
  700. package/.v8-cache/v24.7.0-x64-ef5a0af0/af5cf846 +0 -0
  701. package/.v8-cache/v24.7.0-x64-ef5a0af0/afb5d9e8 +0 -0
  702. package/.v8-cache/v24.7.0-x64-ef5a0af0/afe43898 +0 -0
  703. package/.v8-cache/v24.7.0-x64-ef5a0af0/afec9158 +0 -0
  704. package/.v8-cache/v24.7.0-x64-ef5a0af0/aff3a482 +0 -0
  705. package/.v8-cache/v24.7.0-x64-ef5a0af0/b09573be +0 -0
  706. package/.v8-cache/v24.7.0-x64-ef5a0af0/b09da533 +0 -0
  707. package/.v8-cache/v24.7.0-x64-ef5a0af0/b0a4cf3f +0 -0
  708. package/.v8-cache/v24.7.0-x64-ef5a0af0/b10f835a +0 -0
  709. package/.v8-cache/v24.7.0-x64-ef5a0af0/b1205eb4 +0 -0
  710. package/.v8-cache/v24.7.0-x64-ef5a0af0/b16865d3 +0 -0
  711. package/.v8-cache/v24.7.0-x64-ef5a0af0/b17a6dec +0 -0
  712. package/.v8-cache/v24.7.0-x64-ef5a0af0/b1891195 +0 -0
  713. package/.v8-cache/v24.7.0-x64-ef5a0af0/b189a7f9 +0 -0
  714. package/.v8-cache/v24.7.0-x64-ef5a0af0/b1b2f9d3 +0 -0
  715. package/.v8-cache/v24.7.0-x64-ef5a0af0/b1f3b076 +0 -0
  716. package/.v8-cache/v24.7.0-x64-ef5a0af0/b2fdad6c +0 -0
  717. package/.v8-cache/v24.7.0-x64-ef5a0af0/b30b2046 +0 -0
  718. package/.v8-cache/v24.7.0-x64-ef5a0af0/b3c2fab7 +0 -0
  719. package/.v8-cache/v24.7.0-x64-ef5a0af0/b3d0c11e +0 -0
  720. package/.v8-cache/v24.7.0-x64-ef5a0af0/b410d2c5 +0 -0
  721. package/.v8-cache/v24.7.0-x64-ef5a0af0/b49b2bb7 +0 -0
  722. package/.v8-cache/v24.7.0-x64-ef5a0af0/b5308ceb +0 -0
  723. package/.v8-cache/v24.7.0-x64-ef5a0af0/b53f3bd0 +0 -0
  724. package/.v8-cache/v24.7.0-x64-ef5a0af0/b5bed6cb +0 -0
  725. package/.v8-cache/v24.7.0-x64-ef5a0af0/b5da2388 +0 -0
  726. package/.v8-cache/v24.7.0-x64-ef5a0af0/b629975a +0 -0
  727. package/.v8-cache/v24.7.0-x64-ef5a0af0/b673a402 +0 -0
  728. package/.v8-cache/v24.7.0-x64-ef5a0af0/b77364f2 +0 -0
  729. package/.v8-cache/v24.7.0-x64-ef5a0af0/b80e8bbf +0 -0
  730. package/.v8-cache/v24.7.0-x64-ef5a0af0/b831da0f +0 -0
  731. package/.v8-cache/v24.7.0-x64-ef5a0af0/b8569d6b +0 -0
  732. package/.v8-cache/v24.7.0-x64-ef5a0af0/b877c965 +0 -0
  733. package/.v8-cache/v24.7.0-x64-ef5a0af0/b8b073c4 +0 -0
  734. package/.v8-cache/v24.7.0-x64-ef5a0af0/b8bce506 +0 -0
  735. package/.v8-cache/v24.7.0-x64-ef5a0af0/b8bf4264 +0 -0
  736. package/.v8-cache/v24.7.0-x64-ef5a0af0/b9340404 +0 -0
  737. package/.v8-cache/v24.7.0-x64-ef5a0af0/b93d3c5f +0 -0
  738. package/.v8-cache/v24.7.0-x64-ef5a0af0/b9b8683e +0 -0
  739. package/.v8-cache/v24.7.0-x64-ef5a0af0/b9d3826e +0 -0
  740. package/.v8-cache/v24.7.0-x64-ef5a0af0/ba1b984b +0 -0
  741. package/.v8-cache/v24.7.0-x64-ef5a0af0/ba4a953e +0 -0
  742. package/.v8-cache/v24.7.0-x64-ef5a0af0/ba9eb6f6 +0 -0
  743. package/.v8-cache/v24.7.0-x64-ef5a0af0/bab0ab08 +0 -0
  744. package/.v8-cache/v24.7.0-x64-ef5a0af0/bafcfb84 +0 -0
  745. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb13d80d +0 -0
  746. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb36800b +0 -0
  747. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb39d88f +0 -0
  748. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb489c89 +0 -0
  749. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb69fd4e +0 -0
  750. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb6b8034 +0 -0
  751. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb771b62 +0 -0
  752. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb822c27 +0 -0
  753. package/.v8-cache/v24.7.0-x64-ef5a0af0/bc45333d +0 -0
  754. package/.v8-cache/v24.7.0-x64-ef5a0af0/bc69dc17 +0 -0
  755. package/.v8-cache/v24.7.0-x64-ef5a0af0/bc98c86a +0 -0
  756. package/.v8-cache/v24.7.0-x64-ef5a0af0/bca1b093 +0 -0
  757. package/.v8-cache/v24.7.0-x64-ef5a0af0/bca8d4e0 +0 -0
  758. package/.v8-cache/v24.7.0-x64-ef5a0af0/bd675328 +0 -0
  759. package/.v8-cache/v24.7.0-x64-ef5a0af0/be235b31 +0 -0
  760. package/.v8-cache/v24.7.0-x64-ef5a0af0/be50dd51 +0 -0
  761. package/.v8-cache/v24.7.0-x64-ef5a0af0/be587f65 +0 -0
  762. package/.v8-cache/v24.7.0-x64-ef5a0af0/bec55151 +0 -0
  763. package/.v8-cache/v24.7.0-x64-ef5a0af0/befe29aa +0 -0
  764. package/.v8-cache/v24.7.0-x64-ef5a0af0/bf6130ff +0 -0
  765. package/.v8-cache/v24.7.0-x64-ef5a0af0/bf783b2b +0 -0
  766. package/.v8-cache/v24.7.0-x64-ef5a0af0/bf836239 +0 -0
  767. package/.v8-cache/v24.7.0-x64-ef5a0af0/bf9d4cf2 +0 -0
  768. package/.v8-cache/v24.7.0-x64-ef5a0af0/bfa67430 +0 -0
  769. package/.v8-cache/v24.7.0-x64-ef5a0af0/bfd46e2f +0 -0
  770. package/.v8-cache/v24.7.0-x64-ef5a0af0/c0431ae3 +0 -0
  771. package/.v8-cache/v24.7.0-x64-ef5a0af0/c0b789d2 +0 -0
  772. package/.v8-cache/v24.7.0-x64-ef5a0af0/c0b8f1a6 +0 -0
  773. package/.v8-cache/v24.7.0-x64-ef5a0af0/c110cbb4 +0 -0
  774. package/.v8-cache/v24.7.0-x64-ef5a0af0/c156be25 +0 -0
  775. package/.v8-cache/v24.7.0-x64-ef5a0af0/c1f269f7 +0 -0
  776. package/.v8-cache/v24.7.0-x64-ef5a0af0/c2c12aee +0 -0
  777. package/.v8-cache/v24.7.0-x64-ef5a0af0/c2cd5490 +0 -0
  778. package/.v8-cache/v24.7.0-x64-ef5a0af0/c2e71370 +0 -0
  779. package/.v8-cache/v24.7.0-x64-ef5a0af0/c2e89ba5 +0 -0
  780. package/.v8-cache/v24.7.0-x64-ef5a0af0/c314aece +0 -0
  781. package/.v8-cache/v24.7.0-x64-ef5a0af0/c33c2aa8 +0 -0
  782. package/.v8-cache/v24.7.0-x64-ef5a0af0/c36203b4 +0 -0
  783. package/.v8-cache/v24.7.0-x64-ef5a0af0/c3635a91 +0 -0
  784. package/.v8-cache/v24.7.0-x64-ef5a0af0/c3bf3a3e +0 -0
  785. package/.v8-cache/v24.7.0-x64-ef5a0af0/c3d632bd +0 -0
  786. package/.v8-cache/v24.7.0-x64-ef5a0af0/c3d72b9c +0 -0
  787. package/.v8-cache/v24.7.0-x64-ef5a0af0/c46725e1 +0 -0
  788. package/.v8-cache/v24.7.0-x64-ef5a0af0/c471f274 +0 -0
  789. package/.v8-cache/v24.7.0-x64-ef5a0af0/c494c4b4 +0 -0
  790. package/.v8-cache/v24.7.0-x64-ef5a0af0/c5850517 +0 -0
  791. package/.v8-cache/v24.7.0-x64-ef5a0af0/c6023a8e +0 -0
  792. package/.v8-cache/v24.7.0-x64-ef5a0af0/c62a112f +0 -0
  793. package/.v8-cache/v24.7.0-x64-ef5a0af0/c67edaca +0 -0
  794. package/.v8-cache/v24.7.0-x64-ef5a0af0/c6a94a73 +0 -0
  795. package/.v8-cache/v24.7.0-x64-ef5a0af0/c6d587af +0 -0
  796. package/.v8-cache/v24.7.0-x64-ef5a0af0/c71aa102 +0 -0
  797. package/.v8-cache/v24.7.0-x64-ef5a0af0/c78cdc5c +0 -0
  798. package/.v8-cache/v24.7.0-x64-ef5a0af0/c794cb34 +0 -0
  799. package/.v8-cache/v24.7.0-x64-ef5a0af0/c830c057 +0 -0
  800. package/.v8-cache/v24.7.0-x64-ef5a0af0/c84bb608 +0 -0
  801. package/.v8-cache/v24.7.0-x64-ef5a0af0/c857ade6 +0 -0
  802. package/.v8-cache/v24.7.0-x64-ef5a0af0/c85b1359 +0 -0
  803. package/.v8-cache/v24.7.0-x64-ef5a0af0/c9f25af6 +0 -0
  804. package/.v8-cache/v24.7.0-x64-ef5a0af0/c9fb5ad9 +0 -0
  805. package/.v8-cache/v24.7.0-x64-ef5a0af0/caeca192 +0 -0
  806. package/.v8-cache/v24.7.0-x64-ef5a0af0/caff35bc +0 -0
  807. package/.v8-cache/v24.7.0-x64-ef5a0af0/cb8f2da8 +0 -0
  808. package/.v8-cache/v24.7.0-x64-ef5a0af0/cc40ba20 +0 -0
  809. package/.v8-cache/v24.7.0-x64-ef5a0af0/cc4f384a +0 -0
  810. package/.v8-cache/v24.7.0-x64-ef5a0af0/cc89c1ed +0 -0
  811. package/.v8-cache/v24.7.0-x64-ef5a0af0/ccbf9915 +0 -0
  812. package/.v8-cache/v24.7.0-x64-ef5a0af0/cd4ae980 +0 -0
  813. package/.v8-cache/v24.7.0-x64-ef5a0af0/cd9eed22 +0 -0
  814. package/.v8-cache/v24.7.0-x64-ef5a0af0/ce1833ab +0 -0
  815. package/.v8-cache/v24.7.0-x64-ef5a0af0/ce2d8321 +0 -0
  816. package/.v8-cache/v24.7.0-x64-ef5a0af0/ce41c404 +0 -0
  817. package/.v8-cache/v24.7.0-x64-ef5a0af0/ceb8a7aa +0 -0
  818. package/.v8-cache/v24.7.0-x64-ef5a0af0/cf2c35d3 +0 -0
  819. package/.v8-cache/v24.7.0-x64-ef5a0af0/cf57e0e4 +0 -0
  820. package/.v8-cache/v24.7.0-x64-ef5a0af0/cfb54825 +0 -0
  821. package/.v8-cache/v24.7.0-x64-ef5a0af0/cfc49f4f +0 -0
  822. package/.v8-cache/v24.7.0-x64-ef5a0af0/cff9434a +0 -0
  823. package/.v8-cache/v24.7.0-x64-ef5a0af0/d0008a8c +0 -0
  824. package/.v8-cache/v24.7.0-x64-ef5a0af0/d0250ad2 +0 -0
  825. package/.v8-cache/v24.7.0-x64-ef5a0af0/d02dd6f7 +0 -0
  826. package/.v8-cache/v24.7.0-x64-ef5a0af0/d02e982a +0 -0
  827. package/.v8-cache/v24.7.0-x64-ef5a0af0/d0507bf3 +0 -0
  828. package/.v8-cache/v24.7.0-x64-ef5a0af0/d078d90c +0 -0
  829. package/.v8-cache/v24.7.0-x64-ef5a0af0/d0bf313c +0 -0
  830. package/.v8-cache/v24.7.0-x64-ef5a0af0/d0cc0a90 +0 -0
  831. package/.v8-cache/v24.7.0-x64-ef5a0af0/d1361d27 +0 -0
  832. package/.v8-cache/v24.7.0-x64-ef5a0af0/d14ad268 +0 -0
  833. package/.v8-cache/v24.7.0-x64-ef5a0af0/d156db90 +0 -0
  834. package/.v8-cache/v24.7.0-x64-ef5a0af0/d169f713 +0 -0
  835. package/.v8-cache/v24.7.0-x64-ef5a0af0/d175d850 +0 -0
  836. package/.v8-cache/v24.7.0-x64-ef5a0af0/d1c74c93 +0 -0
  837. package/.v8-cache/v24.7.0-x64-ef5a0af0/d22dbbaf +0 -0
  838. package/.v8-cache/v24.7.0-x64-ef5a0af0/d285e52c +0 -0
  839. package/.v8-cache/v24.7.0-x64-ef5a0af0/d2c313b5 +0 -0
  840. package/.v8-cache/v24.7.0-x64-ef5a0af0/d2e7d08a +0 -0
  841. package/.v8-cache/v24.7.0-x64-ef5a0af0/d2f890e2 +0 -0
  842. package/.v8-cache/v24.7.0-x64-ef5a0af0/d36c2d6c +0 -0
  843. package/.v8-cache/v24.7.0-x64-ef5a0af0/d3782cec +0 -0
  844. package/.v8-cache/v24.7.0-x64-ef5a0af0/d3dfb061 +0 -0
  845. package/.v8-cache/v24.7.0-x64-ef5a0af0/d4538125 +0 -0
  846. package/.v8-cache/v24.7.0-x64-ef5a0af0/d4a032a1 +0 -0
  847. package/.v8-cache/v24.7.0-x64-ef5a0af0/d50a5380 +0 -0
  848. package/.v8-cache/v24.7.0-x64-ef5a0af0/d50e5080 +0 -0
  849. package/.v8-cache/v24.7.0-x64-ef5a0af0/d5bd4b51 +0 -0
  850. package/.v8-cache/v24.7.0-x64-ef5a0af0/d5d61f9a +0 -0
  851. package/.v8-cache/v24.7.0-x64-ef5a0af0/d5da8dd9 +0 -0
  852. package/.v8-cache/v24.7.0-x64-ef5a0af0/d616784e +0 -0
  853. package/.v8-cache/v24.7.0-x64-ef5a0af0/d65a0463 +0 -0
  854. package/.v8-cache/v24.7.0-x64-ef5a0af0/d6cd18fa +0 -0
  855. package/.v8-cache/v24.7.0-x64-ef5a0af0/d6dd70fa +0 -0
  856. package/.v8-cache/v24.7.0-x64-ef5a0af0/d6e08a91 +0 -0
  857. package/.v8-cache/v24.7.0-x64-ef5a0af0/d7050533 +0 -0
  858. package/.v8-cache/v24.7.0-x64-ef5a0af0/d74b7025 +0 -0
  859. package/.v8-cache/v24.7.0-x64-ef5a0af0/d7d680db +0 -0
  860. package/.v8-cache/v24.7.0-x64-ef5a0af0/d7d7317a +0 -0
  861. package/.v8-cache/v24.7.0-x64-ef5a0af0/d8992dac +0 -0
  862. package/.v8-cache/v24.7.0-x64-ef5a0af0/d8dc3671 +0 -0
  863. package/.v8-cache/v24.7.0-x64-ef5a0af0/d8e695f3 +0 -0
  864. package/.v8-cache/v24.7.0-x64-ef5a0af0/d907092d +0 -0
  865. package/.v8-cache/v24.7.0-x64-ef5a0af0/d917a25c +0 -0
  866. package/.v8-cache/v24.7.0-x64-ef5a0af0/d93f46e0 +0 -0
  867. package/.v8-cache/v24.7.0-x64-ef5a0af0/d95719e2 +0 -0
  868. package/.v8-cache/v24.7.0-x64-ef5a0af0/d967f95c +0 -0
  869. package/.v8-cache/v24.7.0-x64-ef5a0af0/d97861bc +0 -0
  870. package/.v8-cache/v24.7.0-x64-ef5a0af0/d9892f45 +0 -0
  871. package/.v8-cache/v24.7.0-x64-ef5a0af0/d9b5e822 +0 -0
  872. package/.v8-cache/v24.7.0-x64-ef5a0af0/da6779d2 +0 -0
  873. package/.v8-cache/v24.7.0-x64-ef5a0af0/da98dfd4 +0 -0
  874. package/.v8-cache/v24.7.0-x64-ef5a0af0/daa5d614 +0 -0
  875. package/.v8-cache/v24.7.0-x64-ef5a0af0/dab50408 +0 -0
  876. package/.v8-cache/v24.7.0-x64-ef5a0af0/db4dcff5 +0 -0
  877. package/.v8-cache/v24.7.0-x64-ef5a0af0/dbdd5317 +0 -0
  878. package/.v8-cache/v24.7.0-x64-ef5a0af0/dc86f000 +0 -0
  879. package/.v8-cache/v24.7.0-x64-ef5a0af0/dcc23fd2 +0 -0
  880. package/.v8-cache/v24.7.0-x64-ef5a0af0/dd2d584e +0 -0
  881. package/.v8-cache/v24.7.0-x64-ef5a0af0/dd3feb06 +0 -0
  882. package/.v8-cache/v24.7.0-x64-ef5a0af0/dd63a73f +0 -0
  883. package/.v8-cache/v24.7.0-x64-ef5a0af0/dd6fce1e +0 -0
  884. package/.v8-cache/v24.7.0-x64-ef5a0af0/dd7f0187 +0 -0
  885. package/.v8-cache/v24.7.0-x64-ef5a0af0/de1358e1 +0 -0
  886. package/.v8-cache/v24.7.0-x64-ef5a0af0/de8a4a0e +0 -0
  887. package/.v8-cache/v24.7.0-x64-ef5a0af0/de92b24b +0 -0
  888. package/.v8-cache/v24.7.0-x64-ef5a0af0/dea00e96 +0 -0
  889. package/.v8-cache/v24.7.0-x64-ef5a0af0/ded97cb3 +0 -0
  890. package/.v8-cache/v24.7.0-x64-ef5a0af0/dedad5f3 +0 -0
  891. package/.v8-cache/v24.7.0-x64-ef5a0af0/df03018c +0 -0
  892. package/.v8-cache/v24.7.0-x64-ef5a0af0/df63f263 +0 -0
  893. package/.v8-cache/v24.7.0-x64-ef5a0af0/df85a9e4 +0 -0
  894. package/.v8-cache/v24.7.0-x64-ef5a0af0/dff8cb13 +0 -0
  895. package/.v8-cache/v24.7.0-x64-ef5a0af0/dfff5d1a +0 -0
  896. package/.v8-cache/v24.7.0-x64-ef5a0af0/e03e2acd +0 -0
  897. package/.v8-cache/v24.7.0-x64-ef5a0af0/e0cb7de8 +0 -0
  898. package/.v8-cache/v24.7.0-x64-ef5a0af0/e1462058 +0 -0
  899. package/.v8-cache/v24.7.0-x64-ef5a0af0/e15267d7 +0 -0
  900. package/.v8-cache/v24.7.0-x64-ef5a0af0/e158d332 +0 -0
  901. package/.v8-cache/v24.7.0-x64-ef5a0af0/e1710fbf +0 -0
  902. package/.v8-cache/v24.7.0-x64-ef5a0af0/e2210767 +0 -0
  903. package/.v8-cache/v24.7.0-x64-ef5a0af0/e23ace36 +0 -0
  904. package/.v8-cache/v24.7.0-x64-ef5a0af0/e26c8da2 +0 -0
  905. package/.v8-cache/v24.7.0-x64-ef5a0af0/e281f8d5 +0 -0
  906. package/.v8-cache/v24.7.0-x64-ef5a0af0/e2e49554 +0 -0
  907. package/.v8-cache/v24.7.0-x64-ef5a0af0/e3c1f166 +0 -0
  908. package/.v8-cache/v24.7.0-x64-ef5a0af0/e3c2381c +0 -0
  909. package/.v8-cache/v24.7.0-x64-ef5a0af0/e440f416 +0 -0
  910. package/.v8-cache/v24.7.0-x64-ef5a0af0/e50b7476 +0 -0
  911. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6381699 +0 -0
  912. package/.v8-cache/v24.7.0-x64-ef5a0af0/e63ff5b9 +0 -0
  913. package/.v8-cache/v24.7.0-x64-ef5a0af0/e65baf3a +0 -0
  914. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6735171 +0 -0
  915. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6745c2b +0 -0
  916. package/.v8-cache/v24.7.0-x64-ef5a0af0/e69219a8 +0 -0
  917. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6b99945 +0 -0
  918. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6de864e +0 -0
  919. package/.v8-cache/v24.7.0-x64-ef5a0af0/e7094c15 +0 -0
  920. package/.v8-cache/v24.7.0-x64-ef5a0af0/e70df5b2 +0 -0
  921. package/.v8-cache/v24.7.0-x64-ef5a0af0/e745da28 +0 -0
  922. package/.v8-cache/v24.7.0-x64-ef5a0af0/e76c5b05 +0 -0
  923. package/.v8-cache/v24.7.0-x64-ef5a0af0/e77e3ab3 +0 -0
  924. package/.v8-cache/v24.7.0-x64-ef5a0af0/e7a1795f +0 -0
  925. package/.v8-cache/v24.7.0-x64-ef5a0af0/e83f7a76 +0 -0
  926. package/.v8-cache/v24.7.0-x64-ef5a0af0/e84f4f9a +0 -0
  927. package/.v8-cache/v24.7.0-x64-ef5a0af0/e8877d49 +0 -0
  928. package/.v8-cache/v24.7.0-x64-ef5a0af0/e889e499 +0 -0
  929. package/.v8-cache/v24.7.0-x64-ef5a0af0/e8b21fee +0 -0
  930. package/.v8-cache/v24.7.0-x64-ef5a0af0/e8b287c3 +0 -0
  931. package/.v8-cache/v24.7.0-x64-ef5a0af0/e97dd9ef +0 -0
  932. package/.v8-cache/v24.7.0-x64-ef5a0af0/e99de3de +0 -0
  933. package/.v8-cache/v24.7.0-x64-ef5a0af0/e9e0179c +0 -0
  934. package/.v8-cache/v24.7.0-x64-ef5a0af0/e9fe9814 +0 -0
  935. package/.v8-cache/v24.7.0-x64-ef5a0af0/eabcc204 +0 -0
  936. package/.v8-cache/v24.7.0-x64-ef5a0af0/eb64b5cd +0 -0
  937. package/.v8-cache/v24.7.0-x64-ef5a0af0/ebbf15fc +0 -0
  938. package/.v8-cache/v24.7.0-x64-ef5a0af0/ebc98ecc +0 -0
  939. package/.v8-cache/v24.7.0-x64-ef5a0af0/ec139485 +0 -0
  940. package/.v8-cache/v24.7.0-x64-ef5a0af0/ec3b7323 +0 -0
  941. package/.v8-cache/v24.7.0-x64-ef5a0af0/ec52b361 +0 -0
  942. package/.v8-cache/v24.7.0-x64-ef5a0af0/ec78b82f +0 -0
  943. package/.v8-cache/v24.7.0-x64-ef5a0af0/ecc029f4 +0 -0
  944. package/.v8-cache/v24.7.0-x64-ef5a0af0/ece6bba0 +0 -0
  945. package/.v8-cache/v24.7.0-x64-ef5a0af0/ecff06c1 +0 -0
  946. package/.v8-cache/v24.7.0-x64-ef5a0af0/ed5e7bde +0 -0
  947. package/.v8-cache/v24.7.0-x64-ef5a0af0/ed99c1d4 +0 -0
  948. package/.v8-cache/v24.7.0-x64-ef5a0af0/ee3e1ad1 +0 -0
  949. package/.v8-cache/v24.7.0-x64-ef5a0af0/ee90f829 +0 -0
  950. package/.v8-cache/v24.7.0-x64-ef5a0af0/eeeebdfe +0 -0
  951. package/.v8-cache/v24.7.0-x64-ef5a0af0/eefa6a26 +0 -0
  952. package/.v8-cache/v24.7.0-x64-ef5a0af0/ef8ac475 +0 -0
  953. package/.v8-cache/v24.7.0-x64-ef5a0af0/efe017e6 +0 -0
  954. package/.v8-cache/v24.7.0-x64-ef5a0af0/f020f5bb +0 -0
  955. package/.v8-cache/v24.7.0-x64-ef5a0af0/f0de5002 +0 -0
  956. package/.v8-cache/v24.7.0-x64-ef5a0af0/f0e87c98 +0 -0
  957. package/.v8-cache/v24.7.0-x64-ef5a0af0/f11cf2e0 +0 -0
  958. package/.v8-cache/v24.7.0-x64-ef5a0af0/f18427f9 +0 -0
  959. package/.v8-cache/v24.7.0-x64-ef5a0af0/f1a87a73 +0 -0
  960. package/.v8-cache/v24.7.0-x64-ef5a0af0/f1ffc102 +0 -0
  961. package/.v8-cache/v24.7.0-x64-ef5a0af0/f292161d +0 -0
  962. package/.v8-cache/v24.7.0-x64-ef5a0af0/f313ac1d +0 -0
  963. package/.v8-cache/v24.7.0-x64-ef5a0af0/f3f12097 +0 -0
  964. package/.v8-cache/v24.7.0-x64-ef5a0af0/f3ff6912 +0 -0
  965. package/.v8-cache/v24.7.0-x64-ef5a0af0/f40eb761 +0 -0
  966. package/.v8-cache/v24.7.0-x64-ef5a0af0/f46cec47 +0 -0
  967. package/.v8-cache/v24.7.0-x64-ef5a0af0/f4cb9649 +0 -0
  968. package/.v8-cache/v24.7.0-x64-ef5a0af0/f4d77aeb +0 -0
  969. package/.v8-cache/v24.7.0-x64-ef5a0af0/f515c638 +0 -0
  970. package/.v8-cache/v24.7.0-x64-ef5a0af0/f5417276 +0 -0
  971. package/.v8-cache/v24.7.0-x64-ef5a0af0/f59beb2e +0 -0
  972. package/.v8-cache/v24.7.0-x64-ef5a0af0/f5ba4d32 +0 -0
  973. package/.v8-cache/v24.7.0-x64-ef5a0af0/f5fa473f +0 -0
  974. package/.v8-cache/v24.7.0-x64-ef5a0af0/f64f7836 +0 -0
  975. package/.v8-cache/v24.7.0-x64-ef5a0af0/f6f867a3 +0 -0
  976. package/.v8-cache/v24.7.0-x64-ef5a0af0/f6fd8125 +0 -0
  977. package/.v8-cache/v24.7.0-x64-ef5a0af0/f7182f57 +0 -0
  978. package/.v8-cache/v24.7.0-x64-ef5a0af0/f73592ff +0 -0
  979. package/.v8-cache/v24.7.0-x64-ef5a0af0/f74d3518 +0 -0
  980. package/.v8-cache/v24.7.0-x64-ef5a0af0/f7639b46 +0 -0
  981. package/.v8-cache/v24.7.0-x64-ef5a0af0/f7c8f5b4 +0 -0
  982. package/.v8-cache/v24.7.0-x64-ef5a0af0/f858e63e +0 -0
  983. package/.v8-cache/v24.7.0-x64-ef5a0af0/f886deac +0 -0
  984. package/.v8-cache/v24.7.0-x64-ef5a0af0/f8c03da6 +0 -0
  985. package/.v8-cache/v24.7.0-x64-ef5a0af0/f9ade3cd +0 -0
  986. package/.v8-cache/v24.7.0-x64-ef5a0af0/fa9d2737 +0 -0
  987. package/.v8-cache/v24.7.0-x64-ef5a0af0/faaaaae8 +0 -0
  988. package/.v8-cache/v24.7.0-x64-ef5a0af0/faad30b7 +0 -0
  989. package/.v8-cache/v24.7.0-x64-ef5a0af0/fb164f4e +0 -0
  990. package/.v8-cache/v24.7.0-x64-ef5a0af0/fb364266 +0 -0
  991. package/.v8-cache/v24.7.0-x64-ef5a0af0/fb6aa9e8 +0 -0
  992. package/.v8-cache/v24.7.0-x64-ef5a0af0/fbbad274 +0 -0
  993. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc0e58aa +0 -0
  994. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc2213f2 +0 -0
  995. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc2e8930 +0 -0
  996. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc35d6bb +0 -0
  997. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc5a7fb3 +0 -0
  998. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc895fea +0 -0
  999. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc97d72d +0 -0
  1000. package/.v8-cache/v24.7.0-x64-ef5a0af0/fc986d28 +0 -0
  1001. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd024c1a +0 -0
  1002. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd0a2987 +0 -0
  1003. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd0b4031 +0 -0
  1004. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd163170 +0 -0
  1005. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd70478c +0 -0
  1006. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd7e8217 +0 -0
  1007. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd7f7e0f +0 -0
  1008. package/.v8-cache/v24.7.0-x64-ef5a0af0/fdffffb0 +0 -0
  1009. package/.v8-cache/v24.7.0-x64-ef5a0af0/fe349423 +0 -0
  1010. package/.v8-cache/v24.7.0-x64-ef5a0af0/fe479403 +0 -0
  1011. package/.v8-cache/v24.7.0-x64-ef5a0af0/fea2f346 +0 -0
  1012. package/.v8-cache/v24.7.0-x64-ef5a0af0/fec5a12f +0 -0
  1013. package/.v8-cache/v24.7.0-x64-ef5a0af0/ff7c87a7 +0 -0
  1014. package/.v8-cache/v24.7.0-x64-ef5a0af0/ff8ea499 +0 -0
  1015. package/.v8-cache/v24.7.0-x64-ef5a0af0/ff967e9d +0 -0
  1016. package/CHANGELOG.md +32 -0
  1017. package/dist/abr.js +12 -5
  1018. package/dist/abr.js.map +1 -1
  1019. package/dist/additionalInfo.d.ts +2 -0
  1020. package/dist/additionalInfo.js +158 -76
  1021. package/dist/additionalInfo.js.map +1 -1
  1022. package/dist/bundle.js +1420 -654
  1023. package/dist/descriptor.d.ts +15 -2
  1024. package/dist/descriptor.js +329 -100
  1025. package/dist/descriptor.js.map +1 -1
  1026. package/dist/effectsHelpers.js +12 -12
  1027. package/dist/effectsHelpers.js.map +1 -1
  1028. package/dist/engineData.d.ts +3 -1
  1029. package/dist/engineData.js +40 -15
  1030. package/dist/engineData.js.map +1 -1
  1031. package/dist/engineData2.js +50 -21
  1032. package/dist/engineData2.js.map +1 -1
  1033. package/dist/helpers.d.ts +5 -2
  1034. package/dist/helpers.js +18 -4
  1035. package/dist/helpers.js.map +1 -1
  1036. package/dist/imageResources.js +58 -32
  1037. package/dist/imageResources.js.map +1 -1
  1038. package/dist/index.js +1 -0
  1039. package/dist/index.js.map +1 -1
  1040. package/dist/jpeg.js +27 -7
  1041. package/dist/jpeg.js.map +1 -1
  1042. package/dist/psd.d.ts +6 -1
  1043. package/dist/psd.js.map +1 -1
  1044. package/dist/psdReader.d.ts +2 -2
  1045. package/dist/psdReader.js +457 -270
  1046. package/dist/psdReader.js.map +1 -1
  1047. package/dist/psdWriter.d.ts +2 -0
  1048. package/dist/psdWriter.js +99 -77
  1049. package/dist/psdWriter.js.map +1 -1
  1050. package/dist/text.js +126 -23
  1051. package/dist/text.js.map +1 -1
  1052. package/dist/utf8.js +36 -15
  1053. package/dist/utf8.js.map +1 -1
  1054. package/dist-es/abr.js +12 -5
  1055. package/dist-es/abr.js.map +1 -1
  1056. package/dist-es/additionalInfo.d.ts +2 -0
  1057. package/dist-es/additionalInfo.js +158 -76
  1058. package/dist-es/additionalInfo.js.map +1 -1
  1059. package/dist-es/descriptor.d.ts +15 -2
  1060. package/dist-es/descriptor.js +329 -100
  1061. package/dist-es/descriptor.js.map +1 -1
  1062. package/dist-es/effectsHelpers.js +12 -12
  1063. package/dist-es/effectsHelpers.js.map +1 -1
  1064. package/dist-es/engineData.d.ts +3 -1
  1065. package/dist-es/engineData.js +40 -15
  1066. package/dist-es/engineData.js.map +1 -1
  1067. package/dist-es/engineData2.js +50 -21
  1068. package/dist-es/engineData2.js.map +1 -1
  1069. package/dist-es/helpers.d.ts +5 -2
  1070. package/dist-es/helpers.js +18 -4
  1071. package/dist-es/helpers.js.map +1 -1
  1072. package/dist-es/imageResources.js +58 -32
  1073. package/dist-es/imageResources.js.map +1 -1
  1074. package/dist-es/index.js +1 -0
  1075. package/dist-es/index.js.map +1 -1
  1076. package/dist-es/jpeg.js +27 -7
  1077. package/dist-es/jpeg.js.map +1 -1
  1078. package/dist-es/psd.d.ts +6 -1
  1079. package/dist-es/psd.js.map +1 -1
  1080. package/dist-es/psdReader.d.ts +2 -2
  1081. package/dist-es/psdReader.js +457 -270
  1082. package/dist-es/psdReader.js.map +1 -1
  1083. package/dist-es/psdWriter.d.ts +2 -0
  1084. package/dist-es/psdWriter.js +99 -77
  1085. package/dist-es/psdWriter.js.map +1 -1
  1086. package/dist-es/text.js +126 -23
  1087. package/dist-es/text.js.map +1 -1
  1088. package/dist-es/utf8.js +36 -15
  1089. package/dist-es/utf8.js.map +1 -1
  1090. package/package.json +1 -1
  1091. package/src/abr.ts +14 -6
  1092. package/src/additionalInfo.ts +166 -75
  1093. package/src/descriptor.ts +347 -107
  1094. package/src/effectsHelpers.ts +9 -9
  1095. package/src/engineData.ts +43 -15
  1096. package/src/engineData2.ts +468 -432
  1097. package/src/helpers.ts +19 -4
  1098. package/src/imageResources.ts +62 -33
  1099. package/src/index.ts +1 -0
  1100. package/src/jpeg.ts +24 -9
  1101. package/src/psd.ts +5 -1
  1102. package/src/psdReader.ts +477 -260
  1103. package/src/psdWriter.ts +101 -84
  1104. package/src/text.ts +122 -12
  1105. package/src/utf8.ts +35 -17
package/dist/bundle.js CHANGED
@@ -7,6 +7,8 @@ const psdReader_1 = require("./psdReader");
7
7
  const dynamicsControl = ['off', 'fade', 'pen pressure', 'pen tilt', 'stylus wheel', 'initial direction', 'direction', 'initial rotation', 'rotation'];
8
8
  const dynamicBrushShapeShapes = ['round point', 'round blunt', 'round curve', 'round angle', 'round fan', 'flat point', 'flat blunt', 'flat curve', 'flat angle', 'flat fan'];
9
9
  const tipsBrushShapeShapes = ['erodible point', 'erodible flat', 'erodible round', 'erodible square', 'erodible triangle', 'custom'];
10
+ // sanity limits for brush sample dimensions (Photoshop brushes are limited to 5000px)
11
+ const MAX_BRUSH_SIZE = 10000;
10
12
  const toBrushType = {
11
13
  _: 'brush',
12
14
  MixB: 'mixer brush',
@@ -113,7 +115,7 @@ function readAbr(buffer, options = {}) {
113
115
  while (reader.offset < reader.view.byteLength) {
114
116
  (0, psdReader_1.checkSignature)(reader, '8BIM');
115
117
  const type = (0, psdReader_1.readSignature)(reader);
116
- let size = (0, psdReader_1.readUint32)(reader);
118
+ const size = (0, psdReader_1.readUint32)(reader);
117
119
  const end = reader.offset + size;
118
120
  switch (type) {
119
121
  case 'samp': {
@@ -132,8 +134,14 @@ function readAbr(buffer, options = {}) {
132
134
  const w = (0, psdReader_1.readInt32)(reader) - x;
133
135
  if (w <= 0 || h <= 0)
134
136
  throw new Error('Invalid bounds');
137
+ if (w > MAX_BRUSH_SIZE || h > MAX_BRUSH_SIZE) {
138
+ throw new Error(`Brush sample too large (${w}x${h})`);
139
+ }
135
140
  const bithDepth = (0, psdReader_1.readInt16)(reader);
136
141
  const compression = (0, psdReader_1.readUint8)(reader); // 0 - raw, 1 - RLE
142
+ if (compression === 0 && w * h * (bithDepth === 16 ? 2 : 1) > brushEnd - reader.offset) {
143
+ throw new Error('Brush sample data out of bounds');
144
+ }
137
145
  const alpha = new Uint8Array(w * h);
138
146
  if (bithDepth === 8) {
139
147
  if (compression === 0) {
@@ -347,11 +355,10 @@ function readAbr(buffer, options = {}) {
347
355
  default:
348
356
  throw new Error(`Invalid brush type: ${type}`);
349
357
  }
350
- // align to 4 bytes
351
- while (size % 4) {
358
+ // skip any unread data in the section and align to 4 bytes
359
+ reader.offset = end;
360
+ while (reader.offset % 4)
352
361
  reader.offset++;
353
- size++;
354
- }
355
362
  }
356
363
  }
357
364
  else {
@@ -395,10 +402,6 @@ function readLength64(reader) {
395
402
  throw new Error(`Resource size above 4 GB limit at ${reader.offset.toString(16)}`);
396
403
  return (0, psdReader_1.readUint32)(reader);
397
404
  }
398
- function writeLength64(writer, length) {
399
- (0, psdWriter_1.writeUint32)(writer, 0);
400
- (0, psdWriter_1.writeUint32)(writer, length);
401
- }
402
405
  addHandler('TySh', hasKey('text'), (reader, target, leftBytes) => {
403
406
  if ((0, psdReader_1.readInt16)(reader) !== 1)
404
407
  throw new Error(`Invalid TySh version`);
@@ -437,7 +440,7 @@ addHandler('TySh', hasKey('text'), (reader, target, leftBytes) => {
437
440
  if (text.boundingBox)
438
441
  target.text.boundingBox = (0, descriptor_1.descBoundsToBounds)(text.boundingBox);
439
442
  if (text.EngineData) {
440
- const engineData = (0, engineData_1.parseEngineData)(text.EngineData);
443
+ const engineData = (0, engineData_1.parseEngineData)(text.EngineData, reader);
441
444
  const textData = (0, text_1.decodeEngineData)(engineData);
442
445
  // console.log(require('util').inspect(engineData, false, 99, false), 'utf8');
443
446
  // require('fs').writeFileSync(`layer-${target.name}.txt`, require('util').inspect(engineData, false, 99, false), 'utf8');
@@ -451,6 +454,7 @@ addHandler('TySh', hasKey('text'), (reader, target, leftBytes) => {
451
454
  }
452
455
  (0, psdReader_1.skipBytes)(reader, leftBytes());
453
456
  }, (writer, target) => {
457
+ var _a, _b, _c, _d;
454
458
  const text = target.text;
455
459
  const warp = text.warp || {};
456
460
  const transform = text.transform || [1, 0, 0, 1, 0, 0];
@@ -463,10 +467,10 @@ addHandler('TySh', hasKey('text'), (reader, target, leftBytes) => {
463
467
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'TxLr', textDescriptor, 'text');
464
468
  (0, psdWriter_1.writeInt16)(writer, 1); // warp version
465
469
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'warp', encodeWarp(warp));
466
- (0, psdWriter_1.writeFloat32)(writer, text.left);
467
- (0, psdWriter_1.writeFloat32)(writer, text.top);
468
- (0, psdWriter_1.writeFloat32)(writer, text.right);
469
- (0, psdWriter_1.writeFloat32)(writer, text.bottom);
470
+ (0, psdWriter_1.writeFloat32)(writer, (_a = text.left) !== null && _a !== void 0 ? _a : 0);
471
+ (0, psdWriter_1.writeFloat32)(writer, (_b = text.top) !== null && _b !== void 0 ? _b : 0);
472
+ (0, psdWriter_1.writeFloat32)(writer, (_c = text.right) !== null && _c !== void 0 ? _c : 0);
473
+ (0, psdWriter_1.writeFloat32)(writer, (_d = text.bottom) !== null && _d !== void 0 ? _d : 0);
470
474
  // writeZeros(writer, 2);
471
475
  });
472
476
  // vector fills
@@ -782,12 +786,50 @@ addHandler('luni', hasKey('name'), (reader, target, left) => {
782
786
  // writeUint16(writer, 0); // padding (but not extending string length)
783
787
  });
784
788
  addHandler('lnsr', hasKey('nameSource'), (reader, target) => target.nameSource = (0, psdReader_1.readSignature)(reader), (writer, target) => (0, psdWriter_1.writeSignature)(writer, target.nameSource));
785
- addHandler('lyid', hasKey('id'), (reader, target) => {
789
+ // these sections reference layer id
790
+ function layerNeedsId(target) {
791
+ return !!(target.animationFrames || target.timeline || target.comps);
792
+ }
793
+ function getExplicitLayerIds(psd, options) {
794
+ if (!options.explicitLayerIds) {
795
+ const ids = new Set();
796
+ const addIds = (layers) => {
797
+ for (const layer of layers !== null && layers !== void 0 ? layers : []) {
798
+ if (layer.id !== undefined)
799
+ ids.add(layer.id);
800
+ addIds(layer.children);
801
+ }
802
+ };
803
+ addIds(psd.children);
804
+ options.explicitLayerIds = ids;
805
+ }
806
+ return options.explicitLayerIds;
807
+ }
808
+ function getLayerId(target, options) {
809
+ var _a;
810
+ const id = (_a = options.layerToId.get(target)) !== null && _a !== void 0 ? _a : target.id;
811
+ if (id === undefined)
812
+ throw new Error('Missing layer id');
813
+ return id;
814
+ }
815
+ addHandler('lyid', target => target.id !== undefined || layerNeedsId(target), (reader, target) => {
786
816
  target.id = (0, psdReader_1.readUint32)(reader);
787
- }, (writer, target, _psd, options) => {
788
- let id = target.id;
789
- while (options.layerIds.has(id))
790
- id += 100; // make sure we don't have duplicate layer ids
817
+ }, (writer, target, psd, options) => {
818
+ var _a;
819
+ let id;
820
+ if (target.id !== undefined) {
821
+ id = target.id;
822
+ while (options.layerIds.has(id))
823
+ id += 100; // make sure we don't have duplicate layer ids
824
+ }
825
+ else {
826
+ // generate id for layers that don't have it, if it's referenced by other sections
827
+ const explicitIds = getExplicitLayerIds(psd, options);
828
+ id = (_a = options.nextGeneratedLayerId) !== null && _a !== void 0 ? _a : 1;
829
+ while (options.layerIds.has(id) || explicitIds.has(id))
830
+ id++;
831
+ options.nextGeneratedLayerId = id + 1;
832
+ }
791
833
  (0, psdWriter_1.writeUint32)(writer, id);
792
834
  options.layerIds.add(id);
793
835
  options.layerToId.set(target, id);
@@ -985,9 +1027,8 @@ target => target.timestamp !== undefined || target.animationFrames !== undefined
985
1027
  (0, psdWriter_1.writeUint8)(writer, 0); // copy (always false)
986
1028
  (0, psdWriter_1.writeZeros)(writer, 3);
987
1029
  (0, psdWriter_1.writeSection)(writer, 2, () => {
988
- var _a;
989
1030
  const desc = {
990
- LaID: (_a = target.id) !== null && _a !== void 0 ? _a : 0,
1031
+ LaID: getLayerId(target, options),
991
1032
  LaSt: [],
992
1033
  };
993
1034
  for (let i = 0; i < animationFrames.length; i++) {
@@ -1043,10 +1084,7 @@ target => target.timestamp !== undefined || target.animationFrames !== undefined
1043
1084
  if (timeline.tracks) {
1044
1085
  desc.trackList = (0, descriptor_1.serializeTrackList)(timeline.tracks);
1045
1086
  }
1046
- const id = options.layerToId.get(target) || target.id;
1047
- if (!id)
1048
- throw new Error('You need to provide layer.id value whan writing document with animations');
1049
- desc.LyrI = id;
1087
+ desc.LyrI = getLayerId(target, options);
1050
1088
  // console.log('WRITE:tmln', target.name, target.id, require('util').inspect(desc, false, 99, true));
1051
1089
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc, 'anim');
1052
1090
  }, true);
@@ -1069,14 +1107,11 @@ target => target.timestamp !== undefined || target.animationFrames !== undefined
1069
1107
  (0, psdWriter_1.writeUint8)(writer, 0); // copy (always false)
1070
1108
  (0, psdWriter_1.writeZeros)(writer, 3);
1071
1109
  (0, psdWriter_1.writeSection)(writer, 2, () => {
1072
- const id = options.layerToId.get(target) || target.id;
1073
- if (!id)
1074
- throw new Error('You need to provide layer.id value whan writing document with layer comps');
1075
1110
  const desc = {};
1076
1111
  if (comps.originalEffectsReferencePoint) {
1077
1112
  desc.origFXRefPoint = { Hrzn: comps.originalEffectsReferencePoint.x, Vrtc: comps.originalEffectsReferencePoint.y };
1078
1113
  }
1079
- desc.LyrI = id;
1114
+ desc.LyrI = getLayerId(target, options);
1080
1115
  desc.layerSettings = [];
1081
1116
  for (const item of comps.settings) {
1082
1117
  const t = {};
@@ -1094,7 +1129,7 @@ target => target.timestamp !== undefined || target.animationFrames !== undefined
1094
1129
  }, true);
1095
1130
  }
1096
1131
  });
1097
- addHandler('PxSc', () => false, (reader, target) => {
1132
+ addHandler('PxSc', hasKey('pixelSource'), (reader, target) => {
1098
1133
  const desc = (0, descriptor_1.readVersionAndDescriptor)(reader, true);
1099
1134
  // console.log('PxSc', require('util').inspect(desc, false, 99, true));
1100
1135
  if (desc.pixelSourceType === 1986285651) {
@@ -1129,7 +1164,7 @@ addHandler('PxSc', () => false, (reader, target) => {
1129
1164
  _classID: 'PixelSource',
1130
1165
  pixelSourceType: 1986285651, // vdP
1131
1166
  descVersion: 1,
1132
- origin: { Hrzn: source.origin.x, Vrtc: source.origin.y },
1167
+ origin: { Hrzn: source.origin.x, Vrtc: source.origin.y }, // written as 'null' class with 'long' values (see writeDescriptorStructure)
1133
1168
  interpretation: {
1134
1169
  _name: '',
1135
1170
  _classID: 'footageInterpretation',
@@ -1371,10 +1406,12 @@ addHandler('PlLd', hasKey('placedLayer'), (reader, target, left) => {
1371
1406
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(warp), type);
1372
1407
  });
1373
1408
  function uint8ToFloat32(array) {
1374
- return new Float32Array(array.buffer.slice(array.byteOffset), 0, array.byteLength / 4);
1409
+ const length = Math.floor(array.byteLength / 4);
1410
+ return new Float32Array(array.buffer.slice(array.byteOffset, array.byteOffset + length * 4), 0, length);
1375
1411
  }
1376
1412
  function uint8ToUint32(array) {
1377
- return new Uint32Array(array.buffer.slice(array.byteOffset), 0, array.byteLength / 4);
1413
+ const length = Math.floor(array.byteLength / 4);
1414
+ return new Uint32Array(array.buffer.slice(array.byteOffset, array.byteOffset + length * 4), 0, length);
1378
1415
  }
1379
1416
  function toUint8(array) {
1380
1417
  return new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
@@ -1643,7 +1680,7 @@ function parseFilterFXItem(f, options) {
1643
1680
  { x: f.Fltr.PuX2, y: f.Fltr.PuY2, },
1644
1681
  { x: f.Fltr.PuX3, y: f.Fltr.PuY3, },
1645
1682
  ],
1646
- puppetShapeList: f.Fltr.puppetShapeList.map(p => ({
1683
+ puppetShapeList: (f.Fltr.puppetShapeList || []).map(p => ({
1647
1684
  rigidType: p.rigidType,
1648
1685
  // TODO: VrsM
1649
1686
  // TODO: VrsN
@@ -2172,7 +2209,7 @@ function serializeFilterFXItem(f) {
2172
2209
  _classID: 'rigidTransform',
2173
2210
  'null': ['Ordn.Trgt'], // TODO: ???
2174
2211
  rigidType: f.filter.rigidType,
2175
- puppetShapeList: f.filter.puppetShapeList.map(p => ({
2212
+ puppetShapeList: (f.filter.puppetShapeList || []).map(p => ({
2176
2213
  _name: '',
2177
2214
  _classID: 'puppetShape',
2178
2215
  rigidType: p.rigidType,
@@ -2257,7 +2294,7 @@ function serializeFilterFXItem(f) {
2257
2294
  _classID: 'perspectiveWarpTransform',
2258
2295
  vertices: f.filter.vertices.map(pointToHrznVrtc),
2259
2296
  warpedVertices: f.filter.warpedVertices.map(pointToHrznVrtc),
2260
- quads: f.filter.quads.map(indices => ({ indices })),
2297
+ quads: f.filter.quads.map(indices => ({ _name: '', _classID: 'quadIndices', indices })),
2261
2298
  }, filterID: 442 });
2262
2299
  case 'curves': return Object.assign(Object.assign({}, base), { Fltr: Object.assign({ _name: 'Curves', _classID: 'Crvs', presetKind: descriptor_1.presetKindType.encode(f.filter.presetKind) }, (f.filter.adjustments ? {
2263
2300
  Adjs: f.filter.adjustments.map(a => 'curve' in a ? {
@@ -2279,10 +2316,13 @@ function serializeFilterFXItem(f) {
2279
2316
  Cntr: f.filter.contrast,
2280
2317
  useLegacy: !!f.filter.useLegacy,
2281
2318
  }, filterID: 1114793795 });
2282
- // case 'hsb/hsl': return {
2283
- // TODO: ...
2284
- // };
2285
- default: throw new Error(`Unknow filter type: ${f.type}`);
2319
+ case 'hsb/hsl': return Object.assign(Object.assign({}, base), { Fltr: {
2320
+ _name: 'HSB/HSL',
2321
+ _classID: 'HsbP',
2322
+ Inpt: descriptor_1.ClrS.encode(f.filter.inputMode),
2323
+ Otpt: descriptor_1.ClrS.encode(f.filter.rowOrder),
2324
+ }, filterID: 1215521360 });
2325
+ default: throw new Error(`Unknown filter type: ${f.type}`);
2286
2326
  }
2287
2327
  }
2288
2328
  // let t: any;
@@ -2373,7 +2413,10 @@ addHandler('SoLd', hasKey('placedLayer'), (reader, target, left) => {
2373
2413
  if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
2374
2414
  throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
2375
2415
  }
2376
- const desc = Object.assign(Object.assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedLayerTypes.indexOf(placed.type), Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform,
2416
+ const placedType = placedLayerTypes.indexOf(placed.type);
2417
+ if (placedType === -1)
2418
+ throw new Error('Invalid placedLayer type');
2419
+ const desc = Object.assign(Object.assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedType, Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform,
2377
2420
  // quiltWarp: {} as any,
2378
2421
  warp: encodeWarp(getWarpFromPlacedLayer(placed)), 'Sz ': {
2379
2422
  _name: '',
@@ -2451,7 +2494,7 @@ addHandler('Lr32', () => false, (reader, _target, _left, psd, imageResources) =>
2451
2494
  addHandler('LMsk', hasKey('userMask'), (reader, target) => {
2452
2495
  target.userMask = {
2453
2496
  colorSpace: (0, psdReader_1.readColor)(reader),
2454
- opacity: (0, psdReader_1.readUint16)(reader) / 0xff,
2497
+ opacity: (0, psdReader_1.readUint16)(reader) / 100,
2455
2498
  };
2456
2499
  const flag = (0, psdReader_1.readUint8)(reader);
2457
2500
  if (flag !== 128)
@@ -2460,7 +2503,7 @@ addHandler('LMsk', hasKey('userMask'), (reader, target) => {
2460
2503
  }, (writer, target) => {
2461
2504
  const userMask = target.userMask;
2462
2505
  (0, psdWriter_1.writeColor)(writer, userMask.colorSpace);
2463
- (0, psdWriter_1.writeUint16)(writer, (0, helpers_1.clamp)(userMask.opacity, 0, 1) * 0xff);
2506
+ (0, psdWriter_1.writeUint16)(writer, Math.round((0, helpers_1.clamp)(userMask.opacity, 0, 1) * 100));
2464
2507
  (0, psdWriter_1.writeUint8)(writer, 128);
2465
2508
  (0, psdWriter_1.writeZeros)(writer, 1);
2466
2509
  });
@@ -2498,7 +2541,7 @@ interface CAIDesc {
2498
2541
  }
2499
2542
 
2500
2543
  addHandler(
2501
- 'CAI ', // content credentials ? something to do with generative tech
2544
+ 'CAI ', // Content Authenticity Initiative
2502
2545
  () => false,
2503
2546
  (reader, _target, left) => {
2504
2547
  const version = readUint32(reader); // 3
@@ -2512,7 +2555,9 @@ addHandler(
2512
2555
  );
2513
2556
  // */
2514
2557
  if (helpers_1.MOCK_HANDLERS) {
2515
- addHandler('CAI ', target => target._CAI_ !== undefined, (reader, target, left) => {
2558
+ addHandler('CAI ', // Content Authenticity Initiative / C2PA provenance metadata
2559
+ // Content Authenticity Initiative / C2PA provenance metadata
2560
+ target => target._CAI_ !== undefined, (reader, target, left) => {
2516
2561
  target._CAI_ = (0, psdReader_1.readBytes)(reader, left());
2517
2562
  }, (writer, target) => {
2518
2563
  (0, psdWriter_1.writeBytes)(writer, target._CAI_);
@@ -2530,8 +2575,8 @@ if (helpers_1.MOCK_HANDLERS) {
2530
2575
  // };
2531
2576
  // }
2532
2577
  if (helpers_1.MOCK_HANDLERS) {
2533
- addHandler('OCIO', // document color management info
2534
- // document color management info
2578
+ addHandler('OCIO', // Document color management info
2579
+ // Document color management info
2535
2580
  target => target._OCIO !== undefined, (reader, target, left) => {
2536
2581
  // const desc = readVersionAndDescriptor(reader, true) as OCIODescriptor;
2537
2582
  // console.log('OCIO', require('util').inspect(desc, false, 99, true));
@@ -2547,8 +2592,8 @@ if (helpers_1.MOCK_HANDLERS) {
2547
2592
  // externalModelList?: [];
2548
2593
  // }
2549
2594
  if (helpers_1.MOCK_HANDLERS) {
2550
- addHandler('GenI', // generative tech
2551
- // generative tech
2595
+ addHandler('GenI', // Generative Fill / generative AI (Firefly) features
2596
+ // Generative Fill / generative AI (Firefly) features
2552
2597
  target => target._GenI !== undefined, (reader, target, left) => {
2553
2598
  // const desc = readVersionAndDescriptor(reader, true); // as GenIDescriptor;
2554
2599
  // console.log('GenI', require('util').inspect(desc, false, 99, true));
@@ -2578,7 +2623,8 @@ addHandler('Anno', target => target.annotations !== undefined, (reader, target,
2578
2623
  const count = (0, psdReader_1.readUint32)(reader);
2579
2624
  const annotations = [];
2580
2625
  for (let i = 0; i < count; i++) {
2581
- /*const length =*/ (0, psdReader_1.readUint32)(reader);
2626
+ const recordStart = reader.offset;
2627
+ const length = (0, psdReader_1.readUint32)(reader); // includes the length field itself
2582
2628
  const type = (0, psdReader_1.readSignature)(reader);
2583
2629
  const open = !!(0, psdReader_1.readUint8)(reader);
2584
2630
  /*const flags =*/ (0, psdReader_1.readUint8)(reader); // always 28
@@ -2594,11 +2640,12 @@ addHandler('Anno', target => target.annotations !== undefined, (reader, target,
2594
2640
  const dataLength = (0, psdReader_1.readUint32)(reader);
2595
2641
  let data;
2596
2642
  if (type === 'txtA') {
2643
+ const dataStart = reader.offset;
2597
2644
  if (dataLength >= 2 && (0, psdReader_1.readUint16)(reader) === 0xfeff) {
2598
- data = (0, psdReader_1.readUnicodeStringWithLength)(reader, (dataLength - 2) / 2);
2645
+ data = (0, psdReader_1.readUnicodeStringWithLength)(reader, Math.floor((dataLength - 2) / 2));
2599
2646
  }
2600
2647
  else {
2601
- reader.offset -= 2;
2648
+ reader.offset = dataStart;
2602
2649
  data = (0, psdReader_1.readAsciiString)(reader, dataLength);
2603
2650
  }
2604
2651
  data = data.replace(/\r/g, '\n');
@@ -2612,6 +2659,8 @@ addHandler('Anno', target => target.annotations !== undefined, (reader, target,
2612
2659
  annotations.push({
2613
2660
  type: type === 'txtA' ? 'text' : 'sound', open, iconLocation, popupLocation, color, author, name, date, data,
2614
2661
  });
2662
+ if (length >= (reader.offset - recordStart))
2663
+ reader.offset = recordStart + length;
2615
2664
  }
2616
2665
  target.annotations = annotations;
2617
2666
  (0, psdReader_1.skipBytes)(reader, left());
@@ -2739,11 +2788,12 @@ function createLnkHandler(tag) {
2739
2788
  }
2740
2789
  (0, psdReader_1.skipBytes)(reader, left()); // ?
2741
2790
  }, (writer, target) => {
2742
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2791
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2743
2792
  const psd = target;
2744
2793
  for (const file of psd.linkedFiles) {
2745
2794
  if ((tag === 'lnkE') !== !!file.linkedFile)
2746
2795
  continue;
2796
+ const external = tag === 'lnkE';
2747
2797
  let version = 2;
2748
2798
  if (file.assetLockedState != null)
2749
2799
  version = 7;
@@ -2751,11 +2801,13 @@ function createLnkHandler(tag) {
2751
2801
  version = 6;
2752
2802
  else if (file.childDocumentID != null)
2753
2803
  version = 5;
2754
- else if (tag === 'lnkE')
2755
- version = 3;
2756
- writeLength64(writer, 0);
2804
+ // liFE version 2 is the only one with embedded data, it has no date and its file size is the size of the data,
2805
+ // versions 5+ can't store the data, so it's not written in that case
2806
+ else if (external && !file.data)
2807
+ version = 4;
2808
+ (0, psdWriter_1.writeUint64)(writer, 0);
2757
2809
  const sizeOffset = writer.offset;
2758
- (0, psdWriter_1.writeSignature)(writer, (tag === 'lnkE') ? 'liFE' : (file.data ? 'liFD' : 'liFA'));
2810
+ (0, psdWriter_1.writeSignature)(writer, external ? 'liFE' : (file.data ? 'liFD' : 'liFA'));
2759
2811
  (0, psdWriter_1.writeInt32)(writer, version);
2760
2812
  if (!file.id || typeof file.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(file.id)) {
2761
2813
  throw new Error('Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
@@ -2764,7 +2816,7 @@ function createLnkHandler(tag) {
2764
2816
  (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, file.name || '');
2765
2817
  (0, psdWriter_1.writeSignature)(writer, file.type ? `${file.type} `.substring(0, 4) : ' ');
2766
2818
  (0, psdWriter_1.writeSignature)(writer, file.creator ? `${file.creator} `.substring(0, 4) : '\0\0\0\0');
2767
- writeLength64(writer, file.data ? file.data.byteLength : 0);
2819
+ (0, psdWriter_1.writeUint64)(writer, (!external && file.data) ? file.data.byteLength : 0);
2768
2820
  if (file.descriptor && file.descriptor.compInfo) {
2769
2821
  const desc = {
2770
2822
  compInfo: {
@@ -2778,7 +2830,7 @@ function createLnkHandler(tag) {
2778
2830
  else {
2779
2831
  (0, psdWriter_1.writeUint8)(writer, 0);
2780
2832
  }
2781
- if (tag === 'lnkE') {
2833
+ if (external) {
2782
2834
  const desc = {
2783
2835
  descVersion: 2,
2784
2836
  'Nm ': (_b = (_a = file.linkedFile) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
@@ -2787,6 +2839,8 @@ function createLnkHandler(tag) {
2787
2839
  relPath: (_h = (_g = file.linkedFile) === null || _g === void 0 ? void 0 : _g.relativePath) !== null && _h !== void 0 ? _h : '',
2788
2840
  };
2789
2841
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'ExternalFileLink', desc);
2842
+ }
2843
+ if (external && version > 3) {
2790
2844
  const time = file.time ? new Date(file.time) : new Date();
2791
2845
  (0, psdWriter_1.writeInt32)(writer, time.getUTCFullYear());
2792
2846
  (0, psdWriter_1.writeUint8)(writer, time.getUTCMonth());
@@ -2795,11 +2849,14 @@ function createLnkHandler(tag) {
2795
2849
  (0, psdWriter_1.writeUint8)(writer, time.getUTCMinutes());
2796
2850
  (0, psdWriter_1.writeFloat64)(writer, time.getUTCSeconds() + time.getUTCMilliseconds() / 1000);
2797
2851
  }
2798
- if (file.data) {
2799
- (0, psdWriter_1.writeBytes)(writer, file.data);
2852
+ if (external) {
2853
+ (0, psdWriter_1.writeUint64)(writer, (version === 2 ? (_j = file.data) === null || _j === void 0 ? void 0 : _j.byteLength : (_k = file.linkedFile) === null || _k === void 0 ? void 0 : _k.fileSize) || 0); // file size
2854
+ }
2855
+ else if (file.data) {
2856
+ (0, psdWriter_1.writeBytes)(writer, file.data); // liFD
2800
2857
  }
2801
2858
  else {
2802
- writeLength64(writer, ((_j = file.linkedFile) === null || _j === void 0 ? void 0 : _j.fileSize) || 0);
2859
+ (0, psdWriter_1.writeZeros)(writer, 8); // liFA
2803
2860
  }
2804
2861
  if (version >= 5)
2805
2862
  (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, file.childDocumentID || '');
@@ -2807,6 +2864,8 @@ function createLnkHandler(tag) {
2807
2864
  (0, psdWriter_1.writeFloat64)(writer, file.assetModTime || 0);
2808
2865
  if (version >= 7)
2809
2866
  (0, psdWriter_1.writeUint8)(writer, file.assetLockedState || 0);
2867
+ if (external && version === 2 && file.data)
2868
+ (0, psdWriter_1.writeBytes)(writer, file.data);
2810
2869
  let size = writer.offset - sizeOffset;
2811
2870
  writer.view.setUint32(sizeOffset - 4, size, false); // write size
2812
2871
  while (size % 4) {
@@ -2895,7 +2954,25 @@ function writeLevelsChannel(writer, channel) {
2895
2954
  addHandler('levl', adjustmentType('levels'), (reader, target, left) => {
2896
2955
  if ((0, psdReader_1.readUint16)(reader) !== 2)
2897
2956
  throw new Error('Invalid levl version');
2898
- target.adjustment = Object.assign(Object.assign({}, target.adjustment), { type: 'levels', rgb: readLevelsChannel(reader), red: readLevelsChannel(reader), green: readLevelsChannel(reader), blue: readLevelsChannel(reader) });
2957
+ const levels = [];
2958
+ for (let i = 0; i < 29 && left(); i++) {
2959
+ levels.push(readLevelsChannel(reader));
2960
+ }
2961
+ const [rgb, red, green, blue] = levels;
2962
+ target.adjustment = Object.assign(Object.assign({}, target.adjustment), { type: 'levels', rgb,
2963
+ red,
2964
+ green,
2965
+ blue });
2966
+ if (left()) {
2967
+ if ((0, psdReader_1.readSignature)(reader) !== 'Lvls')
2968
+ throw new Error(`Invalid levl signature`);
2969
+ if ((0, psdReader_1.readUint16)(reader) !== 3)
2970
+ throw new Error(`Invalid levl version`);
2971
+ const totalChannelRecords = (0, psdReader_1.readUint16)(reader);
2972
+ for (let i = 0; i < (totalChannelRecords - levels.length) && left(); i++) {
2973
+ levels.push(readLevelsChannel(reader));
2974
+ }
2975
+ }
2899
2976
  (0, psdReader_1.skipBytes)(reader, left());
2900
2977
  }, (writer, target) => {
2901
2978
  const info = target.adjustment;
@@ -2911,8 +2988,15 @@ addHandler('levl', adjustmentType('levels'), (reader, target, left) => {
2911
2988
  writeLevelsChannel(writer, info.red || defaultChannel);
2912
2989
  writeLevelsChannel(writer, info.green || defaultChannel);
2913
2990
  writeLevelsChannel(writer, info.blue || defaultChannel);
2914
- for (let i = 0; i < 59; i++)
2991
+ for (let i = 0; i < (29 - 4); i++) {
2992
+ writeLevelsChannel(writer, defaultChannel);
2993
+ }
2994
+ (0, psdWriter_1.writeSignature)(writer, 'Lvls');
2995
+ (0, psdWriter_1.writeUint16)(writer, 3); // version
2996
+ (0, psdWriter_1.writeUint16)(writer, 62); // total count
2997
+ for (let i = 0; i < (62 - 29); i++) {
2915
2998
  writeLevelsChannel(writer, defaultChannel);
2999
+ }
2916
3000
  });
2917
3001
  function readCurveChannel(reader) {
2918
3002
  const nodes = (0, psdReader_1.readUint16)(reader);
@@ -3154,10 +3238,15 @@ addHandler('phfl', adjustmentType('photo filter'), (reader, target, left) => {
3154
3238
  }
3155
3239
  else { // version 3
3156
3240
  // TODO: test this, this is probably wrong
3241
+ // values are stored as L (0..100), a, b (-128..127) multiplied by 100,
3242
+ // normalize them to the same scale as readColor() so they can be written back as version 2
3243
+ const l = (0, psdReader_1.readInt32)(reader) / 100;
3244
+ const a = (0, psdReader_1.readInt32)(reader) / 100;
3245
+ const b = (0, psdReader_1.readInt32)(reader) / 100;
3157
3246
  color = {
3158
- l: (0, psdReader_1.readInt32)(reader) / 100,
3159
- a: (0, psdReader_1.readInt32)(reader) / 100,
3160
- b: (0, psdReader_1.readInt32)(reader) / 100,
3247
+ l: l / 100,
3248
+ a: (0, helpers_1.normalizeLabAB)(a),
3249
+ b: (0, helpers_1.normalizeLabAB)(b),
3161
3250
  };
3162
3251
  }
3163
3252
  target.adjustment = {
@@ -3171,7 +3260,7 @@ addHandler('phfl', adjustmentType('photo filter'), (reader, target, left) => {
3171
3260
  const info = target.adjustment;
3172
3261
  (0, psdWriter_1.writeUint16)(writer, 2); // version
3173
3262
  (0, psdWriter_1.writeColor)(writer, info.color || { l: 0, a: 0, b: 0 });
3174
- (0, psdWriter_1.writeUint32)(writer, (info.density || 0) * 100);
3263
+ (0, psdWriter_1.writeUint32)(writer, Math.round(Math.max(0, info.density || 0) * 100));
3175
3264
  (0, psdWriter_1.writeUint8)(writer, info.preserveLuminosity ? 1 : 0);
3176
3265
  (0, psdWriter_1.writeZeros)(writer, 3);
3177
3266
  });
@@ -3374,10 +3463,11 @@ addHandler('grdm', adjustmentType('gradient map'), (reader, target, left) => {
3374
3463
  (0, psdReader_1.readUint16)(reader) / 0x8000,
3375
3464
  ];
3376
3465
  (0, psdReader_1.skipBytes)(reader, left());
3466
+ // stop locations are always in 0..4096 range, independent of smoothness
3377
3467
  for (const s of info.colorStops)
3378
- s.location /= interpolation;
3468
+ s.location /= 4096;
3379
3469
  for (const s of info.opacityStops)
3380
- s.location /= interpolation;
3470
+ s.location /= 4096;
3381
3471
  target.adjustment = info;
3382
3472
  }, (writer, target) => {
3383
3473
  var _a, _b, _c;
@@ -3390,18 +3480,18 @@ addHandler('grdm', adjustmentType('gradient map'), (reader, target, left) => {
3390
3480
  }
3391
3481
  (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, info.name || '');
3392
3482
  (0, psdWriter_1.writeUint16)(writer, info.colorStops && info.colorStops.length || 0);
3393
- const interpolation = Math.round(((_a = info.smoothness) !== null && _a !== void 0 ? _a : 1) * 4096);
3483
+ const interpolation = Math.round((0, helpers_1.clamp)((_a = info.smoothness) !== null && _a !== void 0 ? _a : 1, 0, 1) * 4096);
3394
3484
  for (const s of info.colorStops || []) {
3395
- (0, psdWriter_1.writeUint32)(writer, Math.round(s.location * interpolation));
3485
+ (0, psdWriter_1.writeUint32)(writer, Math.round((0, helpers_1.clamp)(s.location, 0, 1) * 4096));
3396
3486
  (0, psdWriter_1.writeUint32)(writer, Math.round(s.midpoint * 100));
3397
3487
  (0, psdWriter_1.writeColor)(writer, s.color);
3398
3488
  (0, psdWriter_1.writeZeros)(writer, 2);
3399
3489
  }
3400
3490
  (0, psdWriter_1.writeUint16)(writer, info.opacityStops && info.opacityStops.length || 0);
3401
3491
  for (const s of info.opacityStops || []) {
3402
- (0, psdWriter_1.writeUint32)(writer, Math.round(s.location * interpolation));
3492
+ (0, psdWriter_1.writeUint32)(writer, Math.round((0, helpers_1.clamp)(s.location, 0, 1) * 4096));
3403
3493
  (0, psdWriter_1.writeUint32)(writer, Math.round(s.midpoint * 100));
3404
- (0, psdWriter_1.writeUint16)(writer, Math.round(s.opacity * 0xff));
3494
+ (0, psdWriter_1.writeUint16)(writer, Math.round((0, helpers_1.clamp)(s.opacity, 0, 1) * 0xff));
3405
3495
  }
3406
3496
  (0, psdWriter_1.writeUint16)(writer, 2); // expansion count
3407
3497
  (0, psdWriter_1.writeUint16)(writer, interpolation);
@@ -3563,7 +3653,7 @@ addHandler('Txt2', hasKey('engineData'), (reader, target, left, psd) => {
3563
3653
  const data = (0, psdReader_1.readBytes)(reader, left());
3564
3654
  target.engineData = (0, base64_js_1.fromByteArray)(data);
3565
3655
  const layersByIndex = getTextLayersSortedByIndex(psd);
3566
- const engineData = (0, engineData_1.parseEngineData)(data);
3656
+ const engineData = (0, engineData_1.parseEngineData)(data, reader);
3567
3657
  const engineData2 = (0, engineData2_1.decodeEngineData2)(engineData);
3568
3658
  const TextFrameSet = engineData2.ResourceDict.TextFrameSet;
3569
3659
  if (TextFrameSet) {
@@ -3645,7 +3735,6 @@ addHandler('FEid', hasKey('filterEffectsMasks'), (reader, target, leftBytes) =>
3645
3735
  }
3646
3736
  }
3647
3737
  }, (writer, target) => {
3648
- var _a;
3649
3738
  (0, psdWriter_1.writeInt32)(writer, 3); // version
3650
3739
  for (const mask of target.filterEffectsMasks) {
3651
3740
  (0, psdWriter_1.writeUint32)(writer, 0);
@@ -3674,7 +3763,7 @@ addHandler('FEid', hasKey('filterEffectsMasks'), (reader, target, leftBytes) =>
3674
3763
  }
3675
3764
  }
3676
3765
  writer.view.setUint32(length2Offset - 4, writer.offset - length2Offset, false);
3677
- const extra = (_a = target.filterEffectsMasks[target.filterEffectsMasks.length - 1]) === null || _a === void 0 ? void 0 : _a.extra;
3766
+ const extra = mask.extra;
3678
3767
  if (extra) {
3679
3768
  (0, psdWriter_1.writeUint8)(writer, 1);
3680
3769
  (0, psdWriter_1.writeInt32)(writer, extra.top);
@@ -3698,12 +3787,12 @@ addHandlerAlias('FXid', 'FEid');
3698
3787
  addHandler('FMsk', hasKey('filterMask'), (reader, target) => {
3699
3788
  target.filterMask = {
3700
3789
  colorSpace: (0, psdReader_1.readColor)(reader),
3701
- opacity: (0, psdReader_1.readUint16)(reader) / 0xff,
3790
+ opacity: (0, psdReader_1.readUint16)(reader) / 100,
3702
3791
  };
3703
3792
  }, (writer, target) => {
3704
3793
  var _a;
3705
3794
  (0, psdWriter_1.writeColor)(writer, target.filterMask.colorSpace);
3706
- (0, psdWriter_1.writeUint16)(writer, (0, helpers_1.clamp)((_a = target.filterMask.opacity) !== null && _a !== void 0 ? _a : 1, 0, 1) * 0xff);
3795
+ (0, psdWriter_1.writeUint16)(writer, Math.round((0, helpers_1.clamp)((_a = target.filterMask.opacity) !== null && _a !== void 0 ? _a : 1, 0, 1) * 100));
3707
3796
  });
3708
3797
  addHandler('artd', // document-wide artboard info
3709
3798
  // document-wide artboard info
@@ -3819,12 +3908,12 @@ addHandler('iOpa', hasKey('fillOpacity'), (reader, target) => {
3819
3908
  target.fillOpacity = (0, psdReader_1.readUint8)(reader) / 0xff;
3820
3909
  (0, psdReader_1.skipBytes)(reader, 3);
3821
3910
  }, (writer, target) => {
3822
- (0, psdWriter_1.writeUint8)(writer, target.fillOpacity * 0xff);
3911
+ (0, psdWriter_1.writeUint8)(writer, Math.round((0, helpers_1.clamp)(target.fillOpacity, 0, 1) * 0xff));
3823
3912
  (0, psdWriter_1.writeZeros)(writer, 3);
3824
3913
  });
3825
3914
  addHandler('brst', hasKey('channelBlendingRestrictions'), (reader, target, left) => {
3826
3915
  target.channelBlendingRestrictions = [];
3827
- while (left() > 4) {
3916
+ while (left() >= 4) {
3828
3917
  target.channelBlendingRestrictions.push((0, psdReader_1.readInt32)(reader));
3829
3918
  }
3830
3919
  }, (writer, target) => {
@@ -3895,8 +3984,12 @@ exports.IntC = exports.IntE = exports.Drct = exports.WndM = exports.CntE = expor
3895
3984
  exports.presetKindType = exports.prjM = exports.FlMd = void 0;
3896
3985
  exports.setLogErrors = setLogErrors;
3897
3986
  exports.readAsciiStringOrClassId = readAsciiStringOrClassId;
3987
+ exports.writeAsciiStringOrClassId = writeAsciiStringOrClassId;
3898
3988
  exports.readDescriptorStructure = readDescriptorStructure;
3899
3989
  exports.writeDescriptorStructure = writeDescriptorStructure;
3990
+ exports.createDescriptorReference = createDescriptorReference;
3991
+ exports.pathSelectionStateToReference = pathSelectionStateToReference;
3992
+ exports.writeClassStructure = writeClassStructure;
3900
3993
  exports.readVersionAndDescriptor = readVersionAndDescriptor;
3901
3994
  exports.writeVersionAndDescriptor = writeVersionAndDescriptor;
3902
3995
  exports.horzVrtcToXY = horzVrtcToXY;
@@ -4035,6 +4128,8 @@ const fieldToExtType = {
4035
4128
  origFXRefPoint: nullType,
4036
4129
  FXRefPoint: nullType,
4037
4130
  ClMg: makeType('', 'ClMg'),
4131
+ interpretation: makeType('', 'footageInterpretation'),
4132
+ bgColor: makeType('', 'NativeQuad'),
4038
4133
  };
4039
4134
  const fieldToArrayExtType = {
4040
4135
  'Crv ': makeType('', 'CrPt'),
@@ -4068,6 +4163,9 @@ const fieldToArrayExtType = {
4068
4163
  layerSettings: nullType,
4069
4164
  list: nullType,
4070
4165
  Adjs: makeType('', 'CrvA'),
4166
+ vertices: makeType('', 'Pnt '),
4167
+ warpedVertices: makeType('', 'Pnt '),
4168
+ quads: makeType('', 'quadIndices'),
4071
4169
  };
4072
4170
  const typeToField = {
4073
4171
  'TEXT': [
@@ -4093,6 +4191,7 @@ const typeToField = {
4093
4191
  'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN', 'NmbG', 'WLMn', 'WLMx', 'AmMn', 'AmMx', 'SclH', 'SclV',
4094
4192
  'Lvl ', 'TlNm', 'TlOf', 'FlRs', 'Thsh', 'ShrS', 'ShrE', 'FlRs', 'Vrnc', 'Strg', 'ExtS', 'ExtD',
4095
4193
  'HrzS', 'VrtS', 'NmbR', 'EdgF', 'Ang1', 'Ang2', 'Ang3', 'Ang4', 'lastAppliedComp', 'capturedInfo',
4194
+ 'pixelSourceType',
4096
4195
  ],
4097
4196
  'enum': [
4098
4197
  'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS', 'BlrQ',
@@ -4103,6 +4202,7 @@ const typeToField = {
4103
4202
  'enableCompCoreThreads', 'gs99', 'FrDs', 'trackID', 'animInterpStyle', 'horzAlign',
4104
4203
  'vertAlign', 'bgColorType', 'shapeOperation', 'UndA', 'Wvtp', 'Drct', 'WndM', 'Edg ', 'FlCl', 'IntE',
4105
4204
  'IntC', 'Cnvr', 'Fl ', 'Dstr', 'MztT', 'Lns ', 'ExtT', 'DspM', 'ExtR', 'ZZTy', 'SphM', 'SmBQ', 'placedLayerOCIOConversion', 'gradientsInterpolationMethod',
4205
+ 'interpretAlpha',
4106
4206
  ],
4107
4207
  'bool': [
4108
4208
  'PstS', 'printSixteenBit', 'masterFXSwitch', 'enab', 'uglg', 'antialiasGloss',
@@ -4115,14 +4215,15 @@ const typeToField = {
4115
4215
  'materialsDisclosed', 'hasMotion', 'muted', 'Effc', 'selected', 'autoScope', 'fillCanvas',
4116
4216
  'cellTextIsHTML', 'Smoo', 'Clsp', 'validAtPosition', 'rigidType', 'hasoptions', 'filterMaskEnable',
4117
4217
  'filterMaskLinked', 'filterMaskExtendWithWhite', 'removeJPEGArtifact', 'Mnch', 'ExtF', 'ExtM',
4118
- 'moreAccurate', 'GpuY', 'LIWy', 'Cnty',
4218
+ 'moreAccurate', 'GpuY', 'LIWy', 'Cnty', 'Lnkd', 'showAlteredVideo', 'lightingOn',
4119
4219
  ],
4120
4220
  'doub': [
4121
4221
  'warpValue', 'warpPerspective', 'warpPerspectiveOther', 'Intr', 'Wdth', 'Hght',
4122
4222
  'strokeStyleMiterLimit', 'strokeStyleResolution', 'layerTime', 'keyOriginResolution',
4123
4223
  'xx', 'xy', 'yx', 'yy', 'tx', 'ty', 'FrGA', 'frameRate', 'audioLevel', 'rotation',
4124
4224
  'X ', 'Y ', 'redFloat', 'greenFloat', 'blueFloat', 'imageResolution',
4125
- 'PuX0', 'PuX1', 'PuX2', 'PuX3', 'PuY0', 'PuY1', 'PuY2', 'PuY3'
4225
+ 'PuX0', 'PuX1', 'PuX2', 'PuX3', 'PuY0', 'PuY1', 'PuY2', 'PuY3',
4226
+ 'stylization', 'cleanliness', 'brushScale', 'microBrush', 'specularity',
4126
4227
  ],
4127
4228
  'UntF': [
4128
4229
  'sdwO', 'hglO', 'lagl', 'Lald', 'srgR', 'blur', 'Sftn', 'Opct', 'Dstn', 'Angl',
@@ -4138,14 +4239,57 @@ const typeToField = {
4138
4239
  'warpValues', 'selectedPin', 'Pts ', 'SbpL', 'pathComponents', 'pinOffsets', 'posFinalPins',
4139
4240
  'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList', 'ShrP',
4140
4241
  'channelDenoise', 'Mtrx', 'layerSettings', 'list', 'compList', 'Adjs',
4242
+ 'vertices', 'warpedVertices', 'quads', 'indices', 'Mpng',
4141
4243
  ],
4142
4244
  'ObAr': ['meshPoints', 'quiltSliceX', 'quiltSliceY'],
4143
4245
  'obj ': ['null', 'Chnl'],
4144
4246
  'Pth ': ['DspF'],
4247
+ 'alis': ['alis'],
4145
4248
  };
4146
4249
  const channels = [
4147
4250
  'Rd ', 'Grn ', 'Bl ', 'Yllw', 'Ylw ', 'Cyn ', 'Mgnt', 'Blck', 'Gry ', 'Lmnc', 'A ', 'B ',
4148
4251
  ];
4252
+ // color classes whose channel values are written as doubles ('GRYC' and 'LABC' are kept for backwards compatibility)
4253
+ const doubleColorClasses = ['Grsc', 'LbCl', 'GRYC', 'LABC'];
4254
+ // Hidden (non-enumerable) markers used to remember how values were stored in the file, so they can be
4255
+ // written back the same way. They don't change the shape of the objects returned by the reader.
4256
+ const osTypeKey = typeof Symbol !== 'undefined' ? Symbol('agPsdOSType') : '__agPsdOSType';
4257
+ const obArInfoKey = typeof Symbol !== 'undefined' ? Symbol('agPsdObAr') : '__agPsdObAr';
4258
+ const referenceInfoKey = typeof Symbol !== 'undefined' ? Symbol('agPsdReference') : '__agPsdReference';
4259
+ function setHidden(target, key, value) {
4260
+ Object.defineProperty(target, key, { value, enumerable: false, configurable: true, writable: true });
4261
+ return target;
4262
+ }
4263
+ function getHidden(target, key) {
4264
+ return (target && typeof target === 'object') ? target[key] : undefined;
4265
+ }
4266
+ const osTypeFamilies = {
4267
+ UntF: 'UntF', UnFl: 'UntF',
4268
+ Objc: 'Objc', GlbO: 'Objc',
4269
+ type: 'type', GlbC: 'type',
4270
+ comp: 'comp',
4271
+ };
4272
+ // returns the OS type the value was originally read with, if it's compatible with the type we'd write it as
4273
+ // fallback for unknown keys, based on the type of the value
4274
+ function guessOSType(value) {
4275
+ if (typeof value === 'boolean')
4276
+ return 'bool';
4277
+ if (typeof value === 'number' && !Number.isInteger(value))
4278
+ return 'doub';
4279
+ if (Array.isArray(value))
4280
+ return 'VlLs';
4281
+ if (value && typeof value === 'object' && typeof value._classID === 'string')
4282
+ return 'Objc';
4283
+ return undefined;
4284
+ }
4285
+ function getRecordedOSType(value, type) {
4286
+ const recorded = getHidden(value, osTypeKey);
4287
+ if (!recorded)
4288
+ return type;
4289
+ if (!type || recorded === 'comp' || recorded === 'type' || recorded === 'GlbC')
4290
+ return recorded;
4291
+ return osTypeFamilies[recorded] === osTypeFamilies[type] ? recorded : type;
4292
+ }
4149
4293
  const fieldToArrayType = {
4150
4294
  'Mnm ': 'long',
4151
4295
  'Mxm ': 'long',
@@ -4185,6 +4329,8 @@ const fieldToArrayType = {
4185
4329
  Mtrx: 'long',
4186
4330
  compList: 'long',
4187
4331
  Chnl: 'enum',
4332
+ indices: 'long',
4333
+ Mpng: 'long',
4188
4334
  };
4189
4335
  const fieldToType = {};
4190
4336
  for (const type of Object.keys(typeToField)) {
@@ -4199,6 +4345,7 @@ for (const field of Object.keys(fieldToExtType)) {
4199
4345
  for (const field of Object.keys(fieldToArrayExtType)) {
4200
4346
  fieldToArrayType[field] = 'Objc';
4201
4347
  }
4348
+ const pixelSourceOriginRoot = 'PixelSource.origin';
4202
4349
  function getTypeByKey(key, value, root, parent) {
4203
4350
  if (key === 'presetKind') {
4204
4351
  return typeof value === 'string' ? 'enum' : 'long';
@@ -4218,7 +4365,7 @@ function getTypeByKey(key, value, root, parent) {
4218
4365
  else if (key === 'AntA') {
4219
4366
  return typeof value === 'string' ? 'enum' : 'bool';
4220
4367
  }
4221
- else if ((key === 'Hrzn' || key === 'Vrtc') && (parent.Type === 'keyType.Pstn' || parent._classID === 'Ofst')) {
4368
+ else if ((key === 'Hrzn' || key === 'Vrtc') && (parent.Type === 'keyType.Pstn' || parent._classID === 'Ofst' || root === pixelSourceOriginRoot)) {
4222
4369
  return 'long';
4223
4370
  }
4224
4371
  else if (key === 'Hrzn' || key === 'Vrtc' || key === 'Top ' || key === 'Left' || key === 'Btom' || key === 'Rght') {
@@ -4235,6 +4382,15 @@ function getTypeByKey(key, value, root, parent) {
4235
4382
  else if (key === 'Trnf') {
4236
4383
  return Array.isArray(value) ? 'VlLs' : 'Objc';
4237
4384
  }
4385
+ else if (key === 'alpha' && root === 'slices') {
4386
+ return 'long';
4387
+ }
4388
+ else if ((key === 'Inpt' || key === 'Otpt') && parent._classID === 'HsbP') {
4389
+ return 'enum';
4390
+ }
4391
+ else if (key === 'LghD' && parent._classID === 'oilPaint') {
4392
+ return 'long';
4393
+ }
4238
4394
  else {
4239
4395
  return fieldToType[key];
4240
4396
  }
@@ -4278,23 +4434,22 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
4278
4434
  // write class structure
4279
4435
  (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, name);
4280
4436
  writeAsciiStringOrClassId(writer, classId);
4281
- const keys = Object.keys(value);
4282
- let keyCount = keys.length;
4283
- if ('_name' in value)
4284
- keyCount--;
4285
- if ('_classID' in value)
4286
- keyCount--;
4287
- (0, psdWriter_1.writeUint32)(writer, keyCount);
4437
+ const allKeys = Object.keys(value);
4438
+ const keys = allKeys.filter(key => key !== '_name' && key !== '_classID' && value[key] !== undefined);
4439
+ (0, psdWriter_1.writeUint32)(writer, keys.length);
4288
4440
  for (const key of keys) {
4289
- if (key === '_name' || key === '_classID')
4290
- continue;
4291
4441
  let type = getTypeByKey(key, value[key], root, value);
4442
+ let childRoot = root;
4292
4443
  let extType = fieldToExtType[key];
4293
4444
  if (key === 'bounds' && root === 'text') {
4294
4445
  extType = makeType('', 'bounds');
4295
4446
  }
4296
4447
  else if (key === 'origin') {
4297
4448
  type = root === 'slices' ? 'enum' : 'Objc';
4449
+ if (classId === 'PixelSource') {
4450
+ extType = nullType; // stored as 'null' class with integer Hrzn/Vrtc
4451
+ childRoot = pixelSourceOriginRoot;
4452
+ }
4298
4453
  }
4299
4454
  else if ((key === 'Cyn ' || key === 'Mgnt' || key === 'Ylw ' || key === 'Blck') && value._classID === 'CMYC') {
4300
4455
  type = 'doub';
@@ -4362,10 +4517,14 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
4362
4517
  extType = nullType;
4363
4518
  }
4364
4519
  else if (channels.indexOf(key) !== -1) {
4365
- type = (classId === 'RGBC' && root !== 'artd') ? 'doub' : 'long';
4520
+ type = ((classId === 'RGBC' && root !== 'artd') || doubleColorClasses.indexOf(classId) !== -1) ? 'doub' : 'long';
4366
4521
  }
4367
4522
  else if (key === 'profile') {
4368
- type = classId === 'printOutput' ? 'TEXT' : 'tdta';
4523
+ type = (classId === 'printOutput' || classId === 'proofSetup') ? 'TEXT' : 'tdta';
4524
+ }
4525
+ else if (key === 'alis' && typeof value[key] === 'string') {
4526
+ // 'alis' is read as a binary string (one char per byte), strings with wider chars can only be stored as TEXT
4527
+ type = /[^\x00-\xff]/.test(value[key]) ? 'TEXT' : 'alis';
4369
4528
  }
4370
4529
  else if (key === 'strokeStyleContent') {
4371
4530
  if (value[key]['Clr ']) {
@@ -4389,9 +4548,12 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
4389
4548
  extType = { classID: 'HSBC', name: '' };
4390
4549
  // TODO: other color spaces
4391
4550
  }
4551
+ type = getRecordedOSType(value[key], type);
4552
+ if (!type)
4553
+ type = guessOSType(value[key]);
4392
4554
  writeAsciiStringOrClassId(writer, key);
4393
4555
  (0, psdWriter_1.writeSignature)(writer, type || 'long');
4394
- writeOSType(writer, type || 'long', value[key], key, extType, root);
4556
+ writeOSType(writer, type || 'long', value[key], key, extType, childRoot);
4395
4557
  if (logErrors && !type)
4396
4558
  console.log(`Missing descriptor field type for: '${key}' in`, value);
4397
4559
  }
@@ -4401,8 +4563,9 @@ function readOSType(reader, type, includeClass) {
4401
4563
  case 'obj ': // Reference
4402
4564
  return readReferenceStructure(reader);
4403
4565
  case 'Objc': // Descriptor
4404
- case 'GlbO': // GlobalObject same as Descriptor
4405
4566
  return readDescriptorStructure(reader, includeClass);
4567
+ case 'GlbO': // GlobalObject same as Descriptor
4568
+ return setHidden(readDescriptorStructure(reader, includeClass), osTypeKey, type);
4406
4569
  case 'VlLs': { // List
4407
4570
  const length = (0, psdReader_1.readInt32)(reader);
4408
4571
  const items = [];
@@ -4427,7 +4590,7 @@ function readOSType(reader, type, includeClass) {
4427
4590
  const value = (0, psdReader_1.readFloat32)(reader);
4428
4591
  if (!unitsMap[units])
4429
4592
  throw new Error(`Invalid units: ${units}`);
4430
- return { units: unitsMap[units], value };
4593
+ return setHidden({ units: unitsMap[units], value }, osTypeKey, type);
4431
4594
  }
4432
4595
  case 'TEXT': // String
4433
4596
  return (0, psdReader_1.readUnicodeString)(reader);
@@ -4441,13 +4604,13 @@ function readOSType(reader, type, includeClass) {
4441
4604
  case 'comp': { // Large Integer
4442
4605
  const low = (0, psdReader_1.readUint32)(reader);
4443
4606
  const high = (0, psdReader_1.readUint32)(reader);
4444
- return { low, high };
4607
+ return setHidden({ low, high }, osTypeKey, type);
4445
4608
  }
4446
4609
  case 'bool': // Boolean
4447
4610
  return !!(0, psdReader_1.readUint8)(reader);
4448
4611
  case 'type': // Class
4449
4612
  case 'GlbC': // Class
4450
- return readClassStructure(reader);
4613
+ return setHidden(readClassStructure(reader), osTypeKey, type);
4451
4614
  case 'alis': { // Alias
4452
4615
  const length = (0, psdReader_1.readInt32)(reader);
4453
4616
  return (0, psdReader_1.readAsciiString)(reader, length);
@@ -4459,21 +4622,21 @@ function readOSType(reader, type, includeClass) {
4459
4622
  case 'ObAr': { // Object array
4460
4623
  (0, psdReader_1.readInt32)(reader); // version: 16
4461
4624
  (0, psdReader_1.readUnicodeString)(reader); // name: ''
4462
- readAsciiStringOrClassId(reader); // 'rationalPoint'
4625
+ const classID = readAsciiStringOrClassId(reader); // 'rationalPoint'
4463
4626
  const length = (0, psdReader_1.readInt32)(reader);
4464
4627
  const items = [];
4465
4628
  for (let i = 0; i < length; i++) {
4466
4629
  const type1 = readAsciiStringOrClassId(reader); // type Hrzn | Vrtc
4467
- (0, psdReader_1.readSignature)(reader); // UnFl
4468
- (0, psdReader_1.readSignature)(reader); // units ? '#Pxl'
4630
+ const valueType = (0, psdReader_1.readSignature)(reader); // UnFl
4631
+ const units = (0, psdReader_1.readSignature)(reader); // units ? '#Pxl'
4469
4632
  const valuesCount = (0, psdReader_1.readInt32)(reader);
4470
4633
  const values = [];
4471
4634
  for (let j = 0; j < valuesCount; j++) {
4472
4635
  values.push((0, psdReader_1.readFloat64)(reader));
4473
4636
  }
4474
- items.push({ type: type1, values });
4637
+ items.push(setHidden({ type: type1, values }, obArInfoKey, { valueType, units }));
4475
4638
  }
4476
- return items;
4639
+ return setHidden(items, obArInfoKey, { classID });
4477
4640
  }
4478
4641
  case 'Pth ': { // File path
4479
4642
  /*const length =*/ (0, psdReader_1.readInt32)(reader); // total size of all fields below
@@ -4493,6 +4656,7 @@ const ObArTypes = {
4493
4656
  quiltSliceY: 'UntF',
4494
4657
  };
4495
4658
  function writeOSType(writer, type, value, key, extType, root) {
4659
+ var _a, _b, _c, _d, _e;
4496
4660
  switch (type) {
4497
4661
  case 'obj ': // Reference
4498
4662
  writeReferenceStructure(writer, key, value);
@@ -4501,9 +4665,9 @@ function writeOSType(writer, type, value, key, extType, root) {
4501
4665
  case 'GlbO': { // GlobalObject same as Descriptor
4502
4666
  if (typeof value !== 'object')
4503
4667
  throw new Error(`Invalid struct value: ${JSON.stringify(value)}, key: ${key}`);
4504
- if (!extType)
4668
+ if (!extType && !value._classID)
4505
4669
  throw new Error(`Missing ext type for: '${key}' (${JSON.stringify(value)})`);
4506
- const name = value._name || extType.name;
4670
+ const name = value._name || (extType === null || extType === void 0 ? void 0 : extType.name) || '';
4507
4671
  const classID = value._classID || extType.classID;
4508
4672
  writeDescriptorStructure(writer, name, classID, value, root);
4509
4673
  break;
@@ -4513,7 +4677,7 @@ function writeOSType(writer, type, value, key, extType, root) {
4513
4677
  throw new Error(`Invalid list value: ${JSON.stringify(value)}, key: ${key}`);
4514
4678
  (0, psdWriter_1.writeInt32)(writer, value.length);
4515
4679
  for (let i = 0; i < value.length; i++) {
4516
- const type = fieldToArrayType[key];
4680
+ const type = (_a = getRecordedOSType(value[i], fieldToArrayType[key])) !== null && _a !== void 0 ? _a : guessOSType(value[i]);
4517
4681
  (0, psdWriter_1.writeSignature)(writer, type || 'long');
4518
4682
  writeOSType(writer, type || 'long', value[i], `${key}[]`, fieldToArrayExtType[key], root);
4519
4683
  if (logErrors && !type)
@@ -4551,20 +4715,35 @@ function writeOSType(writer, type, value, key, extType, root) {
4551
4715
  case 'long': // Integer
4552
4716
  if (typeof value !== 'number')
4553
4717
  throw new Error(`Invalid integer value: ${JSON.stringify(value)}, key: ${key}`);
4554
- (0, psdWriter_1.writeInt32)(writer, value);
4718
+ (0, psdWriter_1.writeInt32)(writer, Math.round(value)); // round instead of truncating fractional values
4719
+ break;
4720
+ case 'comp': // Large Integer
4721
+ if (!value || typeof value !== 'object')
4722
+ throw new Error(`Invalid large integer value: ${JSON.stringify(value)}, key: ${key}`);
4723
+ (0, psdWriter_1.writeUint32)(writer, value.low >>> 0);
4724
+ (0, psdWriter_1.writeUint32)(writer, value.high >>> 0);
4555
4725
  break;
4556
- // case 'comp': // Large Integer
4557
- // writeLargeInteger(reader);
4558
4726
  case 'bool': // Boolean
4559
4727
  if (typeof value !== 'boolean')
4560
4728
  throw new Error(`Invalid boolean value: ${JSON.stringify(value)}, key: ${key}`);
4561
4729
  (0, psdWriter_1.writeUint8)(writer, value ? 1 : 0);
4562
4730
  break;
4563
- // case 'type': // Class
4564
- // case 'GlbC': // Class
4565
- // writeClassStructure(reader);
4566
- // case 'alis': // Alias
4567
- // writeAliasStructure(reader);
4731
+ case 'type': // Class
4732
+ case 'GlbC': // Class
4733
+ if (!value || typeof value !== 'object')
4734
+ throw new Error(`Invalid class value: ${JSON.stringify(value)}, key: ${key}`);
4735
+ (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, value.name || '');
4736
+ writeAsciiStringOrClassId(writer, value.classID);
4737
+ break;
4738
+ case 'alis': { // Alias (read as a binary string, one char per byte)
4739
+ if (typeof value !== 'string')
4740
+ throw new Error(`Invalid alias value: ${JSON.stringify(value)}, key: ${key}`);
4741
+ (0, psdWriter_1.writeInt32)(writer, value.length);
4742
+ for (let i = 0; i < value.length; i++) {
4743
+ (0, psdWriter_1.writeUint8)(writer, value.charCodeAt(i) & 0xff);
4744
+ }
4745
+ break;
4746
+ }
4568
4747
  case 'tdta': // Raw Data
4569
4748
  (0, psdWriter_1.writeInt32)(writer, value.byteLength);
4570
4749
  (0, psdWriter_1.writeBytes)(writer, value);
@@ -4572,15 +4751,16 @@ function writeOSType(writer, type, value, key, extType, root) {
4572
4751
  case 'ObAr': { // Object array
4573
4752
  (0, psdWriter_1.writeInt32)(writer, 16); // version
4574
4753
  (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, ''); // name
4575
- const type = ObArTypes[key];
4754
+ const type = (_c = (_b = getHidden(value, obArInfoKey)) === null || _b === void 0 ? void 0 : _b.classID) !== null && _c !== void 0 ? _c : ObArTypes[key];
4576
4755
  if (!type)
4577
4756
  throw new Error(`Not implemented ObArType for: ${key}`);
4578
4757
  writeAsciiStringOrClassId(writer, type);
4579
4758
  (0, psdWriter_1.writeInt32)(writer, value.length);
4580
4759
  for (let i = 0; i < value.length; i++) {
4760
+ const info = getHidden(value[i], obArInfoKey);
4581
4761
  writeAsciiStringOrClassId(writer, value[i].type); // Hrzn | Vrtc
4582
- (0, psdWriter_1.writeSignature)(writer, 'UnFl');
4583
- (0, psdWriter_1.writeSignature)(writer, '#Pxl');
4762
+ (0, psdWriter_1.writeSignature)(writer, (_d = info === null || info === void 0 ? void 0 : info.valueType) !== null && _d !== void 0 ? _d : 'UnFl');
4763
+ (0, psdWriter_1.writeSignature)(writer, (_e = info === null || info === void 0 ? void 0 : info.units) !== null && _e !== void 0 ? _e : '#Pxl');
4584
4764
  (0, psdWriter_1.writeInt32)(writer, value[i].values.length);
4585
4765
  for (let j = 0; j < value[i].values.length; j++) {
4586
4766
  (0, psdWriter_1.writeFloat64)(writer, value[i].values[j]);
@@ -4601,85 +4781,144 @@ function writeOSType(writer, type, value, key, extType, root) {
4601
4781
  throw new Error(`Not implemented descriptor OSType: ${type}`);
4602
4782
  }
4603
4783
  }
4784
+ function referenceItemToValue(item) {
4785
+ switch (item.type) {
4786
+ case 'prop': return item.keyID;
4787
+ case 'Clss': return { name: item.name || '', classID: item.classID };
4788
+ case 'Enmr': return `${item.typeID}.${item.enumValue}`;
4789
+ default: return item.value;
4790
+ }
4791
+ }
4792
+ function referenceItemMatches(item, value) {
4793
+ if (!item)
4794
+ return false;
4795
+ const expected = referenceItemToValue(item);
4796
+ if (expected && typeof expected === 'object') {
4797
+ return !!value && typeof value === 'object' && value.name === expected.name && value.classID === expected.classID;
4798
+ }
4799
+ return expected === value;
4800
+ }
4801
+ // Attaches information about how each item of reference should be written (class IDs, reference types),
4802
+ // the public value of the array stays the same (array of strings/numbers/class objects)
4803
+ function createDescriptorReference(items) {
4804
+ return setHidden(items.map(referenceItemToValue), referenceInfoKey, items);
4805
+ }
4604
4806
  function readReferenceStructure(reader) {
4605
4807
  const itemsCount = (0, psdReader_1.readInt32)(reader);
4606
- const items = [];
4808
+ const infos = [];
4607
4809
  for (let i = 0; i < itemsCount; i++) {
4608
4810
  const type = (0, psdReader_1.readSignature)(reader);
4609
4811
  switch (type) {
4610
4812
  case 'prop': { // Property
4611
- readClassStructure(reader);
4813
+ const { name, classID } = readClassStructure(reader);
4612
4814
  const keyID = readAsciiStringOrClassId(reader);
4613
- items.push(keyID);
4815
+ infos.push({ type, name, classID, keyID });
4614
4816
  break;
4615
4817
  }
4616
- case 'Clss': // Class
4617
- items.push(readClassStructure(reader));
4818
+ case 'Clss': { // Class
4819
+ const { name, classID } = readClassStructure(reader);
4820
+ infos.push({ type, name, classID });
4618
4821
  break;
4822
+ }
4619
4823
  case 'Enmr': { // Enumerated Reference
4620
- readClassStructure(reader);
4824
+ const { name, classID } = readClassStructure(reader);
4621
4825
  const typeID = readAsciiStringOrClassId(reader);
4622
- const value = readAsciiStringOrClassId(reader);
4623
- items.push(`${typeID}.${value}`);
4826
+ const enumValue = readAsciiStringOrClassId(reader);
4827
+ infos.push({ type, name, classID, typeID, enumValue });
4624
4828
  break;
4625
4829
  }
4626
4830
  case 'rele': { // Offset
4627
- // const { name, classID } =
4628
- readClassStructure(reader);
4629
- items.push((0, psdReader_1.readUint32)(reader));
4831
+ const { name, classID } = readClassStructure(reader);
4832
+ infos.push({ type, name, classID, value: (0, psdReader_1.readUint32)(reader) });
4630
4833
  break;
4631
4834
  }
4632
4835
  case 'Idnt': // Identifier
4633
- items.push((0, psdReader_1.readInt32)(reader));
4634
- break;
4635
4836
  case 'indx': // Index
4636
- items.push((0, psdReader_1.readInt32)(reader));
4837
+ infos.push({ type, value: (0, psdReader_1.readInt32)(reader) });
4637
4838
  break;
4638
4839
  case 'name': { // Name
4639
- readClassStructure(reader);
4640
- items.push((0, psdReader_1.readUnicodeString)(reader));
4840
+ const { name, classID } = readClassStructure(reader);
4841
+ infos.push({ type, name, classID, value: (0, psdReader_1.readUnicodeString)(reader) });
4641
4842
  break;
4642
4843
  }
4643
4844
  default:
4644
4845
  throw new Error(`Invalid descriptor reference type: ${type}`);
4645
4846
  }
4646
4847
  }
4647
- return items;
4848
+ return createDescriptorReference(infos);
4849
+ }
4850
+ function guessReferenceItem(value) {
4851
+ if (typeof value === 'string') {
4852
+ // enumerated references are read as `${typeID}.${enumValue}` where typeID is a 4 character ID or a string ID
4853
+ // (values like 'My.Path' or 'Logo.v2' can't be typeID/enum value, so they are written as name references)
4854
+ const match = /^([a-z ]{4}|[a-z]{5,})\.([a-z ]+)$/i.exec(value);
4855
+ if (match) {
4856
+ return { type: 'Enmr', name: '', classID: match[1], typeID: match[1], enumValue: match[2] };
4857
+ }
4858
+ else {
4859
+ return { type: 'name', name: '', classID: 'Lyr ', value };
4860
+ }
4861
+ }
4862
+ else if (typeof value === 'number') {
4863
+ return { type: 'Idnt', value };
4864
+ }
4865
+ else if (value && typeof value === 'object' && typeof value.classID === 'string') {
4866
+ return { type: 'Clss', name: value.name || '', classID: value.classID };
4867
+ }
4868
+ else {
4869
+ throw new Error(`Invalid descriptor reference value: ${JSON.stringify(value)}`);
4870
+ }
4871
+ }
4872
+ // path selection state (image resource 1088) is a reference to paths, enumerated references there use 'Path' class
4873
+ // (name references use 'Lyr ' class, they reference layer of the vector mask)
4874
+ function pathSelectionStateToReference(items) {
4875
+ const infos = getHidden(items, referenceInfoKey);
4876
+ return createDescriptorReference(items.map((value, i) => {
4877
+ if (referenceItemMatches(infos === null || infos === void 0 ? void 0 : infos[i], value))
4878
+ return infos[i]; // keep information read from the file
4879
+ const item = guessReferenceItem(value);
4880
+ if (item.type === 'Enmr')
4881
+ item.classID = 'Path';
4882
+ return item;
4883
+ }));
4648
4884
  }
4649
4885
  function writeReferenceStructure(writer, _key, items) {
4886
+ if (!Array.isArray(items))
4887
+ throw new Error(`Invalid reference value: ${JSON.stringify(items)}, key: ${_key}`);
4888
+ const infos = getHidden(items, referenceInfoKey);
4650
4889
  (0, psdWriter_1.writeInt32)(writer, items.length);
4651
4890
  for (let i = 0; i < items.length; i++) {
4652
4891
  const value = items[i];
4653
- let type = 'unknown';
4654
- if (typeof value === 'string') {
4655
- if (/^[a-z ]+\.[a-z ]+$/i.test(value)) {
4656
- type = 'Enmr';
4657
- }
4658
- else {
4659
- type = 'name';
4660
- }
4661
- }
4662
- (0, psdWriter_1.writeSignature)(writer, type);
4663
- switch (type) {
4664
- // case 'prop': // Property
4665
- // case 'Clss': // Class
4666
- case 'Enmr': { // Enumerated Reference
4667
- const [typeID, enumValue] = value.split('.');
4668
- writeClassStructure(writer, '\0', typeID);
4669
- writeAsciiStringOrClassId(writer, typeID);
4670
- writeAsciiStringOrClassId(writer, enumValue);
4892
+ const recorded = infos === null || infos === void 0 ? void 0 : infos[i];
4893
+ const item = referenceItemMatches(recorded, value) ? recorded : guessReferenceItem(value);
4894
+ (0, psdWriter_1.writeSignature)(writer, item.type);
4895
+ switch (item.type) {
4896
+ case 'prop': // Property
4897
+ writeClassStructure(writer, item.name || '', item.classID);
4898
+ writeAsciiStringOrClassId(writer, item.keyID);
4671
4899
  break;
4672
- }
4673
- // case 'rele': // Offset
4674
- // case 'Idnt': // Identifier
4675
- // case 'indx': // Index
4676
- case 'name': { // Name
4677
- writeClassStructure(writer, '\0', 'Lyr ');
4678
- (0, psdWriter_1.writeUnicodeString)(writer, value + '\0');
4900
+ case 'Clss': // Class
4901
+ writeClassStructure(writer, item.name || '', item.classID);
4902
+ break;
4903
+ case 'Enmr': // Enumerated Reference
4904
+ writeClassStructure(writer, item.name || '', item.classID);
4905
+ writeAsciiStringOrClassId(writer, item.typeID);
4906
+ writeAsciiStringOrClassId(writer, item.enumValue);
4907
+ break;
4908
+ case 'rele': // Offset
4909
+ writeClassStructure(writer, item.name || '', item.classID);
4910
+ (0, psdWriter_1.writeUint32)(writer, item.value);
4911
+ break;
4912
+ case 'Idnt': // Identifier
4913
+ case 'indx': // Index
4914
+ (0, psdWriter_1.writeInt32)(writer, item.value);
4915
+ break;
4916
+ case 'name': // Name
4917
+ writeClassStructure(writer, item.name || '', item.classID);
4918
+ (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, `${item.value}`);
4679
4919
  break;
4680
- }
4681
4920
  default:
4682
- throw new Error(`Invalid descriptor reference type: ${type}`);
4921
+ throw new Error(`Invalid descriptor reference type: ${item.type}`);
4683
4922
  }
4684
4923
  }
4685
4924
  return items;
@@ -4690,7 +4929,7 @@ function readClassStructure(reader) {
4690
4929
  return { name, classID };
4691
4930
  }
4692
4931
  function writeClassStructure(writer, name, classID) {
4693
- (0, psdWriter_1.writeUnicodeString)(writer, name);
4932
+ (0, psdWriter_1.writeUnicodeStringWithPadding)(writer, name);
4694
4933
  writeAsciiStringOrClassId(writer, classID);
4695
4934
  }
4696
4935
  function readVersionAndDescriptor(reader, includeClass = false) {
@@ -4822,9 +5061,11 @@ function serializeEffects(e, log, multi) {
4822
5061
  info.numModifyingFX = 0;
4823
5062
  for (const key of Object.keys(e)) {
4824
5063
  const value = e[key];
5064
+ if (value == null || typeof value !== 'object')
5065
+ continue;
4825
5066
  if (Array.isArray(value)) {
4826
5067
  for (const effect of value) {
4827
- if (effect.enabled)
5068
+ if (effect === null || effect === void 0 ? void 0 : effect.enabled)
4828
5069
  info.numModifyingFX++;
4829
5070
  }
4830
5071
  }
@@ -4973,7 +5214,7 @@ function serializeTrackList(tracks) {
4973
5214
  const t = tracks[i];
4974
5215
  trackList.push(Object.assign(Object.assign({ trackID: exports.stdTrackID.encode(t.type), Vrsn: 1, enab: !!t.enabled, Effc: !!t.effectParams }, (t.effectParams ? {
4975
5216
  effectParams: {
4976
- keyList: serializeKeyList(t.keys),
5217
+ keyList: serializeKeyList(t.effectParams.keys),
4977
5218
  fillCanvas: t.effectParams.fillCanvas,
4978
5219
  zoomOrigin: t.effectParams.zoomOrigin,
4979
5220
  }
@@ -5216,7 +5457,7 @@ function serializeEffectObject(obj, objName, reportErrors) {
5216
5457
  result.sdwO = unitsPercent(val);
5217
5458
  break;
5218
5459
  case 'angle':
5219
- if (objName === 'gradientOverlay' || objName === 'patternFill') {
5460
+ if (objName === 'gradientOverlay' || objName === 'patternOverlay') {
5220
5461
  result.Angl = unitsAngle(val);
5221
5462
  }
5222
5463
  else {
@@ -5288,7 +5529,8 @@ function serializeEffectObject(obj, objName, reportErrors) {
5288
5529
  }
5289
5530
  function parseGradient(grad) {
5290
5531
  if (grad.GrdF === 'GrdF.CstS') {
5291
- const samples = grad.Intr || 4096;
5532
+ // stop locations are always in 0..4096 range, independent of smoothness (Intr)
5533
+ const samples = 4096;
5292
5534
  return {
5293
5535
  type: 'solid',
5294
5536
  name: grad['Nm '],
@@ -5322,11 +5564,12 @@ function parseGradient(grad) {
5322
5564
  function serializeGradient(grad) {
5323
5565
  var _a, _b;
5324
5566
  if (grad.type === 'solid') {
5325
- const samples = Math.round(((_a = grad.smoothness) !== null && _a !== void 0 ? _a : 1) * 4096);
5567
+ // stop locations are always in 0..4096 range, independent of smoothness (Intr)
5568
+ const samples = 4096;
5326
5569
  return {
5327
5570
  'Nm ': grad.name || '',
5328
5571
  GrdF: 'GrdF.CstS',
5329
- Intr: samples,
5572
+ Intr: Math.round(((_a = grad.smoothness) !== null && _a !== void 0 ? _a : 1) * 4096),
5330
5573
  Clrs: grad.colorStops.map(s => {
5331
5574
  var _a;
5332
5575
  return ({
@@ -5355,8 +5598,8 @@ function serializeGradient(grad) {
5355
5598
  ClrS: exports.ClrS.encode(grad.colorModel),
5356
5599
  RndS: grad.randomSeed || 0,
5357
5600
  Smth: Math.round(((_b = grad.roughness) !== null && _b !== void 0 ? _b : 1) * 4096),
5358
- 'Mnm ': (grad.min || [0, 0, 0, 0]).map(x => x * 100),
5359
- 'Mxm ': (grad.max || [1, 1, 1, 1]).map(x => x * 100),
5601
+ 'Mnm ': (grad.min || [0, 0, 0, 0]).map(x => Math.round(x * 100)),
5602
+ 'Mxm ': (grad.max || [1, 1, 1, 1]).map(x => Math.round(x * 100)),
5360
5603
  };
5361
5604
  }
5362
5605
  }
@@ -5456,21 +5699,65 @@ function serializeVectorContent(content) {
5456
5699
  return { key: 'GdFl', descriptor: serializeGradientContent(content) };
5457
5700
  }
5458
5701
  }
5702
+ // Descriptor color values: HSB saturation/brightness 0..100, CMYK 0..100, Gray 0..100, Lab L 0..100, a/b -128..127
5703
+ // Color values (see psd.ts): HSB 0..1, CMYK 0..255, Gray 0..255, Lab L 0..1, a/b -1..1 (same as readColor/writeColor)
5704
+ const colorSourceKey = typeof Symbol !== 'undefined' ? Symbol('agPsdColorSource') : '__agPsdColorSource';
5705
+ const colorConversions = {
5706
+ // key: [descriptor -> color, color -> descriptor]
5707
+ Strt: [x => x / 100, x => x * 100],
5708
+ Brgh: [x => x / 100, x => x * 100],
5709
+ 'Cyn ': [x => x * 255 / 100, x => x * 100 / 255],
5710
+ Mgnt: [x => x * 255 / 100, x => x * 100 / 255],
5711
+ 'Ylw ': [x => x * 255 / 100, x => x * 100 / 255],
5712
+ Blck: [x => x * 255 / 100, x => x * 100 / 255],
5713
+ 'Gry ': [x => x * 255 / 100, x => x * 100 / 255],
5714
+ Lmnc: [x => x / 100, x => x * 100],
5715
+ 'A ': [helpers_1.normalizeLabAB, helpers_1.denormalizeLabAB],
5716
+ 'B ': [helpers_1.normalizeLabAB, helpers_1.denormalizeLabAB],
5717
+ };
5718
+ function colorToDescriptorValue(key, value) {
5719
+ const conversion = colorConversions[key];
5720
+ if (!conversion)
5721
+ return value;
5722
+ const [from, to] = conversion;
5723
+ const result = to(value);
5724
+ if (!isFinite(result))
5725
+ return result;
5726
+ // prefer shortest number that converts back to the same value (avoids values like 30.200000000000003)
5727
+ for (let precision = 1; precision < 17; precision++) {
5728
+ const candidate = +result.toPrecision(precision);
5729
+ if (from(candidate) === value)
5730
+ return candidate;
5731
+ }
5732
+ return result;
5733
+ }
5734
+ function shallowEqual(a, b) {
5735
+ const keys = Object.keys(a);
5736
+ if (keys.length !== Object.keys(b).length)
5737
+ return false;
5738
+ return keys.every(key => a[key] === b[key]);
5739
+ }
5459
5740
  function parseColor(color) {
5741
+ let result;
5460
5742
  if ('H ' in color) {
5461
- return { h: parsePercentOrAngle(color['H ']), s: color.Strt, b: color.Brgh };
5743
+ result = { h: parsePercentOrAngle(color['H ']), s: color.Strt / 100, b: color.Brgh / 100 };
5462
5744
  }
5463
5745
  else if ('Rd ' in color) {
5464
5746
  return { r: color['Rd '], g: color['Grn '], b: color['Bl '] };
5465
5747
  }
5466
5748
  else if ('Cyn ' in color) {
5467
- return { c: color['Cyn '], m: color.Mgnt, y: color['Ylw '], k: color.Blck };
5749
+ result = {
5750
+ c: color['Cyn '] * 255 / 100,
5751
+ m: color.Mgnt * 255 / 100,
5752
+ y: color['Ylw '] * 255 / 100,
5753
+ k: color.Blck * 255 / 100,
5754
+ };
5468
5755
  }
5469
5756
  else if ('Gry ' in color) {
5470
- return { k: color['Gry '] };
5757
+ result = { k: color['Gry '] * 255 / 100 };
5471
5758
  }
5472
5759
  else if ('Lmnc' in color) {
5473
- return { l: color.Lmnc, a: color['A '], b: color['B '] };
5760
+ result = { l: color.Lmnc / 100, a: (0, helpers_1.normalizeLabAB)(color['A ']), b: (0, helpers_1.normalizeLabAB)(color['B ']) };
5474
5761
  }
5475
5762
  else if ('redFloat' in color) {
5476
5763
  return { fr: color.redFloat, fg: color.greenFloat, fb: color.blueFloat };
@@ -5478,8 +5765,10 @@ function parseColor(color) {
5478
5765
  else {
5479
5766
  throw new Error('Unsupported color descriptor');
5480
5767
  }
5768
+ // remember original descriptor values, so unmodified colors can be written back without conversion errors
5769
+ return setHidden(result, colorSourceKey, { color: Object.assign({}, result), descriptor: color });
5481
5770
  }
5482
- function serializeColor(color) {
5771
+ function serializeColorValues(color) {
5483
5772
  if (!color) {
5484
5773
  return { _name: '', _classID: 'RGBC', 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
5485
5774
  }
@@ -5490,21 +5779,50 @@ function serializeColor(color) {
5490
5779
  return { _name: '', _classID: 'RGBC', redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
5491
5780
  }
5492
5781
  else if ('h' in color) {
5493
- return { _name: '', _classID: 'HSBC', 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
5782
+ return {
5783
+ _name: '', _classID: 'HSBC',
5784
+ 'H ': unitsAngle((color.h || 0) * 360),
5785
+ Strt: colorToDescriptorValue('Strt', color.s || 0),
5786
+ Brgh: colorToDescriptorValue('Brgh', color.b || 0),
5787
+ };
5494
5788
  }
5495
5789
  else if ('c' in color) {
5496
- return { _name: '', _classID: 'CMYC', 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
5790
+ return {
5791
+ _name: '', _classID: 'CMYC',
5792
+ 'Cyn ': colorToDescriptorValue('Cyn ', color.c || 0),
5793
+ Mgnt: colorToDescriptorValue('Mgnt', color.m || 0),
5794
+ 'Ylw ': colorToDescriptorValue('Ylw ', color.y || 0),
5795
+ Blck: colorToDescriptorValue('Blck', color.k || 0),
5796
+ };
5497
5797
  }
5498
5798
  else if ('l' in color) {
5499
- return { _name: '', _classID: 'LABC', Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
5799
+ return {
5800
+ _name: '', _classID: 'LbCl',
5801
+ Lmnc: colorToDescriptorValue('Lmnc', color.l || 0),
5802
+ 'A ': colorToDescriptorValue('A ', color.a || 0),
5803
+ 'B ': colorToDescriptorValue('B ', color.b || 0),
5804
+ };
5500
5805
  }
5501
5806
  else if ('k' in color) {
5502
- return { _name: '', _classID: 'GRYC', 'Gry ': color.k };
5807
+ return { _name: '', _classID: 'Grsc', 'Gry ': colorToDescriptorValue('Gry ', color.k || 0) };
5503
5808
  }
5504
5809
  else {
5505
5810
  throw new Error('Invalid color value');
5506
5811
  }
5507
5812
  }
5813
+ function serializeColor(color) {
5814
+ const result = serializeColorValues(color);
5815
+ const source = getHidden(color, colorSourceKey);
5816
+ if (source && shallowEqual(source.color, color)) {
5817
+ // color was not modified since it was read, use exact original values
5818
+ for (const key of Object.keys(result)) {
5819
+ if (colorConversions[key] && typeof source.descriptor[key] === 'number') {
5820
+ result[key] = source.descriptor[key];
5821
+ }
5822
+ }
5823
+ }
5824
+ return result;
5825
+ }
5508
5826
  function parseAngle(x) {
5509
5827
  if (x === undefined)
5510
5828
  return 0;
@@ -5921,9 +6239,9 @@ function readEffects(reader) {
5921
6239
  case 'cmnS': { // common state (see See Effects layer, common state info)
5922
6240
  const size = (0, psdReader_1.readUint32)(reader);
5923
6241
  const version = (0, psdReader_1.readUint32)(reader);
5924
- const visible = !!(0, psdReader_1.readUint8)(reader);
6242
+ (0, psdReader_1.readUint8)(reader); // visible (not reliable, Photoshop writes 1 even if effects are disabled)
5925
6243
  (0, psdReader_1.skipBytes)(reader, 2);
5926
- if (size !== 7 || version !== 0 || !visible)
6244
+ if (size !== 7 || version !== 0)
5927
6245
  throw new Error(`Invalid effects common state`);
5928
6246
  break;
5929
6247
  }
@@ -6071,7 +6389,7 @@ function writeShadowInfo(writer, shadow) {
6071
6389
  (0, psdWriter_1.writeColor)(writer, shadow.color); // native color
6072
6390
  }
6073
6391
  function writeEffects(writer, effects) {
6074
- var _a, _b, _c, _d, _e, _f;
6392
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
6075
6393
  const dropShadow = (_a = effects.dropShadow) === null || _a === void 0 ? void 0 : _a[0];
6076
6394
  const innerShadow = (_b = effects.innerShadow) === null || _b === void 0 ? void 0 : _b[0];
6077
6395
  const outerGlow = effects.outerGlow;
@@ -6097,7 +6415,7 @@ function writeEffects(writer, effects) {
6097
6415
  (0, psdWriter_1.writeSignature)(writer, 'cmnS');
6098
6416
  (0, psdWriter_1.writeUint32)(writer, 7); // size
6099
6417
  (0, psdWriter_1.writeUint32)(writer, 0); // version
6100
- (0, psdWriter_1.writeUint8)(writer, 1); // visible
6418
+ (0, psdWriter_1.writeUint8)(writer, 1); // visible (Photoshop writes 1 here even if effects are disabled)
6101
6419
  (0, psdWriter_1.writeZeros)(writer, 2);
6102
6420
  if (dropShadow) {
6103
6421
  (0, psdWriter_1.writeSignature)(writer, '8BIM');
@@ -6119,7 +6437,7 @@ function writeEffects(writer, effects) {
6119
6437
  (0, psdWriter_1.writeColor)(writer, outerGlow.color);
6120
6438
  writeBlendMode(writer, outerGlow.blendMode);
6121
6439
  (0, psdWriter_1.writeUint8)(writer, outerGlow.enabled ? 1 : 0);
6122
- writeFixedPoint8(writer, outerGlow.opacity || 0);
6440
+ writeFixedPoint8(writer, (_e = outerGlow.opacity) !== null && _e !== void 0 ? _e : 1);
6123
6441
  (0, psdWriter_1.writeColor)(writer, outerGlow.color);
6124
6442
  }
6125
6443
  if (innerGlow) {
@@ -6127,12 +6445,12 @@ function writeEffects(writer, effects) {
6127
6445
  (0, psdWriter_1.writeSignature)(writer, 'iglw');
6128
6446
  (0, psdWriter_1.writeUint32)(writer, 43);
6129
6447
  (0, psdWriter_1.writeUint32)(writer, 2);
6130
- (0, psdWriter_1.writeFixedPoint32)(writer, ((_e = innerGlow.size) === null || _e === void 0 ? void 0 : _e.value) || 0);
6448
+ (0, psdWriter_1.writeFixedPoint32)(writer, ((_f = innerGlow.size) === null || _f === void 0 ? void 0 : _f.value) || 0);
6131
6449
  (0, psdWriter_1.writeFixedPoint32)(writer, 0); // intensity
6132
6450
  (0, psdWriter_1.writeColor)(writer, innerGlow.color);
6133
6451
  writeBlendMode(writer, innerGlow.blendMode);
6134
6452
  (0, psdWriter_1.writeUint8)(writer, innerGlow.enabled ? 1 : 0);
6135
- writeFixedPoint8(writer, innerGlow.opacity || 0);
6453
+ writeFixedPoint8(writer, (_g = innerGlow.opacity) !== null && _g !== void 0 ? _g : 1);
6136
6454
  (0, psdWriter_1.writeUint8)(writer, 0); // inverted
6137
6455
  (0, psdWriter_1.writeColor)(writer, innerGlow.color);
6138
6456
  }
@@ -6143,15 +6461,15 @@ function writeEffects(writer, effects) {
6143
6461
  (0, psdWriter_1.writeUint32)(writer, 2);
6144
6462
  (0, psdWriter_1.writeFixedPoint32)(writer, bevel.angle || 0);
6145
6463
  (0, psdWriter_1.writeFixedPoint32)(writer, bevel.strength || 0);
6146
- (0, psdWriter_1.writeFixedPoint32)(writer, ((_f = bevel.size) === null || _f === void 0 ? void 0 : _f.value) || 0);
6464
+ (0, psdWriter_1.writeFixedPoint32)(writer, ((_h = bevel.size) === null || _h === void 0 ? void 0 : _h.value) || 0);
6147
6465
  writeBlendMode(writer, bevel.highlightBlendMode);
6148
6466
  writeBlendMode(writer, bevel.shadowBlendMode);
6149
6467
  (0, psdWriter_1.writeColor)(writer, bevel.highlightColor);
6150
6468
  (0, psdWriter_1.writeColor)(writer, bevel.shadowColor);
6151
6469
  const style = bevelStyles.indexOf(bevel.style);
6152
- (0, psdWriter_1.writeUint8)(writer, style <= 0 ? 1 : style);
6153
- writeFixedPoint8(writer, bevel.highlightOpacity || 0);
6154
- writeFixedPoint8(writer, bevel.shadowOpacity || 0);
6470
+ (0, psdWriter_1.writeUint8)(writer, style <= 0 ? bevelStyles.indexOf('inner bevel') : style); // reader defaults to inner bevel
6471
+ writeFixedPoint8(writer, (_j = bevel.highlightOpacity) !== null && _j !== void 0 ? _j : 1);
6472
+ writeFixedPoint8(writer, (_k = bevel.shadowOpacity) !== null && _k !== void 0 ? _k : 1);
6155
6473
  (0, psdWriter_1.writeUint8)(writer, bevel.enabled ? 1 : 0);
6156
6474
  (0, psdWriter_1.writeUint8)(writer, bevel.useGlobalLight ? 1 : 0);
6157
6475
  (0, psdWriter_1.writeUint8)(writer, bevel.direction === 'down' ? 1 : 0);
@@ -6165,7 +6483,7 @@ function writeEffects(writer, effects) {
6165
6483
  (0, psdWriter_1.writeUint32)(writer, 2);
6166
6484
  writeBlendMode(writer, solidFill.blendMode);
6167
6485
  (0, psdWriter_1.writeColor)(writer, solidFill.color);
6168
- writeFixedPoint8(writer, solidFill.opacity || 0);
6486
+ writeFixedPoint8(writer, (_l = solidFill.opacity) !== null && _l !== void 0 ? _l : 1);
6169
6487
  (0, psdWriter_1.writeUint8)(writer, solidFill.enabled ? 1 : 0);
6170
6488
  (0, psdWriter_1.writeColor)(writer, solidFill.color);
6171
6489
  }
@@ -6174,6 +6492,7 @@ function writeEffects(writer, effects) {
6174
6492
  },{"./helpers":8,"./psdReader":13,"./psdWriter":14}],6:[function(require,module,exports){
6175
6493
  "use strict";
6176
6494
  Object.defineProperty(exports, "__esModule", { value: true });
6495
+ exports.setProperty = setProperty;
6177
6496
  exports.parseEngineData = parseEngineData;
6178
6497
  exports.serializeEngineData = serializeEngineData;
6179
6498
  function isWhitespace(char) {
@@ -6184,7 +6503,15 @@ function isNumber(char) {
6184
6503
  // 0123456789.-
6185
6504
  return (char >= 48 && char <= 57) || char === 46 || char === 45;
6186
6505
  }
6187
- function parseEngineData(data) {
6506
+ function setProperty(target, key, value) {
6507
+ if (key === '__proto__') { // avoid changing prototype of the object
6508
+ Object.defineProperty(target, key, { value, enumerable: true, configurable: true, writable: true });
6509
+ }
6510
+ else {
6511
+ target[key] = value;
6512
+ }
6513
+ }
6514
+ function parseEngineData(data, reader) {
6188
6515
  let index = 0;
6189
6516
  function skipWhitespace() {
6190
6517
  while (index < data.length && isWhitespace(data[index])) {
@@ -6206,9 +6533,13 @@ function parseEngineData(data) {
6206
6533
  index++;
6207
6534
  return result;
6208
6535
  }
6209
- // Strings start with utf-16 BOM
6536
+ // Strings usually start with utf-16 BOM, strings without it are single-byte (e.g. "(01110)" in Txt2)
6210
6537
  if (data[index] !== 0xFE || data[index + 1] !== 0xFF) {
6211
- throw new Error('Invalid utf-16 BOM');
6538
+ while (index < data.length && data[index] !== 41) { // )
6539
+ result += String.fromCharCode(getTextByte());
6540
+ }
6541
+ index++;
6542
+ return result;
6212
6543
  }
6213
6544
  index += 2;
6214
6545
  // ), ( and \ characters are escaped in ascii manner, remove the escapes before interpreting
@@ -6239,7 +6570,8 @@ function parseEngineData(data) {
6239
6570
  throw new Error('Invalid data');
6240
6571
  const top = stack[stack.length - 1];
6241
6572
  if (typeof top === 'string') {
6242
- stack[stack.length - 2][top] = value;
6573
+ const target = stack[stack.length - 2];
6574
+ setProperty(target, top, value);
6243
6575
  pop();
6244
6576
  }
6245
6577
  else if (Array.isArray(top)) {
@@ -6253,7 +6585,8 @@ function parseEngineData(data) {
6253
6585
  if (!stack.length)
6254
6586
  pushContainer({});
6255
6587
  const top = stack[stack.length - 1];
6256
- if (top && typeof top === 'string') {
6588
+ if (typeof top === 'string' || Array.isArray(top)) {
6589
+ // name used as a value (either property value or array item)
6257
6590
  if (name === 'nil') {
6258
6591
  pushValue(null);
6259
6592
  }
@@ -6275,6 +6608,8 @@ function parseEngineData(data) {
6275
6608
  }
6276
6609
  skipWhitespace();
6277
6610
  let dataLength = data.length;
6611
+ let invalidTokens = 0;
6612
+ let firstInvalidToken = '';
6278
6613
  while (dataLength > 0 && data[dataLength - 1] === 0)
6279
6614
  dataLength--; // trim 0 bytes from end
6280
6615
  while (index < dataLength) {
@@ -6334,14 +6669,16 @@ function parseEngineData(data) {
6334
6669
  }
6335
6670
  else {
6336
6671
  index += 1;
6337
- console.log(`Invalid token '${String.fromCharCode(char)}' (${char}) at ${index}`
6338
- // + ` near '${String.fromCharCode.apply(null, data.slice(index - 10, index + 20) as any)}'`
6339
- // + ` data [${Array.from(data.slice(index - 10, index + 20)).join(', ')}]`
6340
- );
6672
+ if (!invalidTokens)
6673
+ firstInvalidToken = `'${String.fromCharCode(char)}' (${char}) at ${index}`;
6674
+ invalidTokens++;
6341
6675
  // throw new Error(`Invalid token ${String.fromCharCode(char)} at ${index}`);
6342
6676
  }
6343
6677
  skipWhitespace();
6344
6678
  }
6679
+ if (invalidTokens) {
6680
+ reader.log(`Invalid tokens in engine data (${invalidTokens} in total, first: ${firstInvalidToken})`);
6681
+ }
6345
6682
  return root;
6346
6683
  }
6347
6684
  const floatKeys = [
@@ -6351,7 +6688,6 @@ const floatKeys = [
6351
6688
  'OutlineWidth', 'AutoLeading',
6352
6689
  ];
6353
6690
  const intArrays = ['RunLengthArray'];
6354
- // TODO: handle /nil
6355
6691
  function serializeEngineData(data, condensed = false) {
6356
6692
  let buffer = new Uint8Array(1024);
6357
6693
  let offset = 0;
@@ -6387,16 +6723,21 @@ function serializeEngineData(data, condensed = false) {
6387
6723
  if (!condensed)
6388
6724
  writeString('\n');
6389
6725
  }
6726
+ // NaN and Infinity can't be represented in engine data, write them as 0
6727
+ function finite(value) {
6728
+ return Number.isFinite(value) ? value : 0;
6729
+ }
6390
6730
  function serializeInt(value) {
6391
- return value.toString();
6731
+ return finite(value).toString();
6392
6732
  }
6393
6733
  function serializeFloat(value) {
6394
- return value.toFixed(5)
6734
+ return finite(value).toFixed(5)
6395
6735
  .replace(/(\d)0+$/g, '$1')
6396
6736
  .replace(/^0+\.([1-9])/g, '.$1')
6397
6737
  .replace(/^-0+\.0(\d)/g, '-.0$1');
6398
6738
  }
6399
6739
  function serializeNumber(value, key) {
6740
+ value = finite(value);
6400
6741
  const isFloat = (key && floatKeys.indexOf(key) !== -1) || (value | 0) !== value;
6401
6742
  return isFloat ? serializeFloat(value) : serializeInt(value);
6402
6743
  }
@@ -6423,7 +6764,7 @@ function serializeEngineData(data, condensed = false) {
6423
6764
  writeIndent();
6424
6765
  }
6425
6766
  }
6426
- if (value === null) {
6767
+ if (value === null || value === undefined) { // undefined is only written for array items, properties are skipped
6427
6768
  writePrefix();
6428
6769
  writeString(condensed ? '/nil' : 'null');
6429
6770
  }
@@ -6485,7 +6826,8 @@ function serializeEngineData(data, condensed = false) {
6485
6826
  writeString('\n');
6486
6827
  indent++;
6487
6828
  for (const key of getKeys(value)) {
6488
- writeProperty(key, value[key]);
6829
+ if (value[key] !== undefined)
6830
+ writeProperty(key, value[key]);
6489
6831
  }
6490
6832
  indent--;
6491
6833
  writeIndent();
@@ -6496,7 +6838,8 @@ function serializeEngineData(data, condensed = false) {
6496
6838
  if (condensed) {
6497
6839
  if (typeof data === 'object') {
6498
6840
  for (const key of getKeys(data)) {
6499
- writeProperty(key, data[key]);
6841
+ if (data[key] !== undefined)
6842
+ writeProperty(key, data[key]);
6500
6843
  }
6501
6844
  }
6502
6845
  }
@@ -6513,6 +6856,7 @@ function serializeEngineData(data, condensed = false) {
6513
6856
  // /test/engineData2.json:1109 is character codes
6514
6857
  Object.defineProperty(exports, "__esModule", { value: true });
6515
6858
  exports.decodeEngineData2 = decodeEngineData2;
6859
+ const engineData_1 = require("./engineData");
6516
6860
  const keysColor = {
6517
6861
  '0': {
6518
6862
  uproot: true,
@@ -6883,48 +7227,78 @@ const keysRoot = {
6883
7227
  },
6884
7228
  },
6885
7229
  };
6886
- function decodeObj(obj, keys) {
7230
+ const MAX_DEPTH = 256;
7231
+ function getKey(keys, key) {
7232
+ return Object.prototype.hasOwnProperty.call(keys, key) ? keys[key] : undefined;
7233
+ }
7234
+ function decodeObj(obj, keys, depth) {
6887
7235
  var _a, _b;
6888
- if (obj === null)
7236
+ if (depth > MAX_DEPTH)
7237
+ throw new Error(`Engine data is nested too deeply (more than ${MAX_DEPTH} levels)`);
7238
+ if (obj === null || obj === undefined)
6889
7239
  return obj;
6890
7240
  if (Array.isArray(obj))
6891
- return obj.map(x => decodeObj(x, keys));
7241
+ return obj.map(x => decodeObj(x, keys, depth + 1));
6892
7242
  if (typeof obj !== 'object')
6893
7243
  return obj;
6894
- let result = {};
6895
- for (const key of Object.keys(obj)) {
6896
- if (keys[key]) {
6897
- if (keys[key].uproot) {
6898
- if (key !== '99')
6899
- result = decodeObj(obj[key], (_a = keys[key].children) !== null && _a !== void 0 ? _a : {});
6900
- if (obj['99'])
6901
- result._type = obj['99'];
6902
- break;
6903
- }
6904
- else {
6905
- result[keys[key].name || key] = decodeObj(obj[key], (_b = keys[key].children) !== null && _b !== void 0 ? _b : {});
6906
- }
6907
- }
6908
- else if (key === '99') {
6909
- result._type = obj[key];
7244
+ const objKeys = Object.keys(obj);
7245
+ const uprootKey = objKeys.find(key => { var _a; return key !== '99' && ((_a = getKey(keys, key)) === null || _a === void 0 ? void 0 : _a.uproot); });
7246
+ let result;
7247
+ if (uprootKey !== undefined) {
7248
+ // replace the object with the value of the uprooted key
7249
+ result = decodeObj(obj[uprootKey], (_a = getKey(keys, uprootKey).children) !== null && _a !== void 0 ? _a : {}, depth + 1);
7250
+ // primitive values can't hold extra properties (type and sibling keys are dropped)
7251
+ if (result === null || typeof result !== 'object')
7252
+ return result;
7253
+ if (obj['99'])
7254
+ result._type = obj['99'];
7255
+ if (Array.isArray(result))
7256
+ return result;
7257
+ }
7258
+ else {
7259
+ result = {};
7260
+ }
7261
+ for (const key of objKeys) {
7262
+ if (key === uprootKey)
7263
+ continue;
7264
+ const info = getKey(keys, key);
7265
+ if (key === '99') {
7266
+ if (uprootKey === undefined)
7267
+ result._type = obj[key];
6910
7268
  }
6911
7269
  else {
6912
- result[key] = decodeObj(obj[key], {});
7270
+ const name = (info === null || info === void 0 ? void 0 : info.name) || key;
7271
+ // don't overwrite fields of uprooted object with sibling keys
7272
+ if (uprootKey === undefined || !(name in result)) {
7273
+ (0, engineData_1.setProperty)(result, name, decodeObj(obj[key], (_b = info === null || info === void 0 ? void 0 : info.children) !== null && _b !== void 0 ? _b : {}, depth + 1));
7274
+ }
6913
7275
  }
6914
7276
  }
6915
7277
  return result;
6916
7278
  }
7279
+ function emptyResourceDict() {
7280
+ return { FontSet: [], StyleSheetSet: [], ParagraphSheetSet: [] };
7281
+ }
6917
7282
  function decodeEngineData2(data) {
6918
- return decodeObj(data, keysRoot);
7283
+ const result = decodeObj(data, keysRoot, 0);
7284
+ if (!result || typeof result !== 'object' || Array.isArray(result)) {
7285
+ return { ResourceDict: emptyResourceDict(), EngineDict: {} };
7286
+ }
7287
+ if (!result.ResourceDict || typeof result.ResourceDict !== 'object') {
7288
+ result.ResourceDict = emptyResourceDict();
7289
+ }
7290
+ return result;
6919
7291
  }
6920
7292
 
6921
- },{}],8:[function(require,module,exports){
7293
+ },{"./engineData":6}],8:[function(require,module,exports){
6922
7294
  "use strict";
6923
7295
  Object.defineProperty(exports, "__esModule", { value: true });
6924
7296
  exports.createImageData = exports.createCanvas = exports.MaskParams = exports.LayerMaskFlags = exports.ColorSpace = exports.largeAdditionalInfoKeys = exports.layerColors = exports.toBlendMode = exports.fromBlendMode = exports.RAW_IMAGE_DATA = exports.MOCK_HANDLERS = void 0;
6925
7297
  exports.revMap = revMap;
6926
7298
  exports.createEnum = createEnum;
6927
7299
  exports.offsetForChannel = offsetForChannel;
7300
+ exports.normalizeLabAB = normalizeLabAB;
7301
+ exports.denormalizeLabAB = denormalizeLabAB;
6928
7302
  exports.clamp = clamp;
6929
7303
  exports.hasAlpha = hasAlpha;
6930
7304
  exports.resetImageData = resetImageData;
@@ -7044,6 +7418,13 @@ function offsetForChannel(channelId, cmyk) {
7044
7418
  default: return channelId + 1;
7045
7419
  }
7046
7420
  }
7421
+ // Lab a/b components are stored in -128..127 range (multiplied by scale), normalized values are in -1..1 range
7422
+ function normalizeLabAB(value, scale = 1) {
7423
+ return value < 0 ? (value / (128 * scale)) : (value / (127 * scale));
7424
+ }
7425
+ function denormalizeLabAB(value, scale = 1) {
7426
+ return value < 0 ? (value * (128 * scale)) : (value * (127 * scale));
7427
+ }
7047
7428
  function clamp(value, min, max) {
7048
7429
  return value < min ? min : (value > max ? max : value);
7049
7430
  }
@@ -7119,9 +7500,10 @@ function writeDataRaw(data, offset, width, height) {
7119
7500
  }
7120
7501
  return array;
7121
7502
  }
7503
+ // returns view into the buffer, the buffer has to fit worst case size (see getRLEChannelBound), throws if it doesn't
7122
7504
  function writeDataRLE(buffer, { data, width, height }, offsets, large) {
7123
7505
  if (!width || !height)
7124
- return undefined;
7506
+ return buffer.subarray(0, 0);
7125
7507
  const stride = (4 * width) | 0;
7126
7508
  let ol = 0;
7127
7509
  let o = (offsets.length * (large ? 4 : 2) * height) | 0;
@@ -7198,6 +7580,9 @@ function writeDataRLE(buffer, { data, width, height }, offsets, large) {
7198
7580
  buffer[o++] = data[p];
7199
7581
  }
7200
7582
  }
7583
+ // writes past the end of typed array are ignored, so it's enough to check the size after each row
7584
+ if (o > buffer.length)
7585
+ throw new Error(`RLE buffer too small (${buffer.length})`);
7201
7586
  const length = o - startOffset;
7202
7587
  if (large) {
7203
7588
  buffer[ol++] = (length >> 24) & 0xff;
@@ -7207,7 +7592,8 @@ function writeDataRLE(buffer, { data, width, height }, offsets, large) {
7207
7592
  buffer[ol++] = length & 0xff;
7208
7593
  }
7209
7594
  }
7210
- return buffer.slice(0, o);
7595
+ // returns view of the buffer, copy the data if the buffer is going to be reused
7596
+ return buffer.subarray(0, o);
7211
7597
  }
7212
7598
  function writeDataZipWithoutPrediction({ data, width, height }, offsets) {
7213
7599
  const size = width * height;
@@ -7235,7 +7621,7 @@ function writeDataZipWithoutPrediction({ data, width, height }, offsets) {
7235
7621
  return buffers[0];
7236
7622
  }
7237
7623
  }
7238
- function createCanvasFromData(data) {
7624
+ function createCanvasFromData(data, reader) {
7239
7625
  const canvas = (0, exports.createCanvas)(100, 100);
7240
7626
  try {
7241
7627
  const context = canvas.getContext('2d');
@@ -7245,7 +7631,7 @@ function createCanvasFromData(data) {
7245
7631
  context.putImageData(imageData, 0, 0);
7246
7632
  }
7247
7633
  catch (e) {
7248
- console.error('JPEG decompression error', e.message);
7634
+ reader.log('JPEG decompression error', e.message);
7249
7635
  }
7250
7636
  return canvas;
7251
7637
  }
@@ -7312,6 +7698,18 @@ function writeUtf8String(writer, value) {
7312
7698
  const buffer = (0, utf8_1.encodeString)(value);
7313
7699
  (0, psdWriter_1.writeBytes)(writer, buffer);
7314
7700
  }
7701
+ let gbkDecoder;
7702
+ function getGbkDecoder() {
7703
+ if (gbkDecoder === undefined) {
7704
+ try {
7705
+ gbkDecoder = new TextDecoder('gbk');
7706
+ }
7707
+ catch (_a) {
7708
+ gbkDecoder = null;
7709
+ }
7710
+ }
7711
+ return gbkDecoder;
7712
+ }
7315
7713
  function readEncodedString(reader) {
7316
7714
  const length = (0, psdReader_1.readUint8)(reader);
7317
7715
  const buffer = (0, psdReader_1.readBytes)(reader, length);
@@ -7323,19 +7721,26 @@ function readEncodedString(reader) {
7323
7721
  }
7324
7722
  }
7325
7723
  if (notAscii) {
7326
- try {
7327
- const decoder = new TextDecoder('gbk');
7328
- return decoder.decode(buffer);
7724
+ const decoder = getGbkDecoder();
7725
+ if (decoder) {
7726
+ try {
7727
+ return decoder.decode(buffer);
7728
+ }
7729
+ catch (_a) { }
7329
7730
  }
7330
- catch (_a) { }
7331
7731
  }
7332
7732
  return (0, utf8_1.decodeString)(buffer);
7333
7733
  }
7334
7734
  function writeEncodedString(writer, value) {
7335
7735
  let ascii = '';
7336
- for (let i = 0, code = value.codePointAt(i++); code !== undefined; code = value.codePointAt(i++)) {
7337
- ascii += code > 0x7f ? '?' : String.fromCodePoint(code);
7736
+ for (let i = 0; i < value.length;) {
7737
+ const code = value.codePointAt(i);
7738
+ ascii += code > 0x7f ? '?' : String.fromCharCode(code);
7739
+ i += code > 0xffff ? 2 : 1; // skip low surrogate of astral characters
7338
7740
  }
7741
+ // length is stored in a single byte
7742
+ if (ascii.length > 255)
7743
+ ascii = ascii.substring(0, 255);
7339
7744
  const buffer = (0, utf8_1.encodeString)(ascii);
7340
7745
  (0, psdWriter_1.writeUint8)(writer, buffer.byteLength);
7341
7746
  (0, psdWriter_1.writeBytes)(writer, buffer);
@@ -7540,7 +7945,7 @@ addHandler(1053, target => target.alphaIdentifiers !== undefined, (reader, targe
7540
7945
  addHandler(1010, target => target.backgroundColor !== undefined, (reader, target) => target.backgroundColor = (0, psdReader_1.readColor)(reader), (writer, target) => (0, psdWriter_1.writeColor)(writer, target.backgroundColor));
7541
7946
  addHandler(1037, target => target.globalAngle !== undefined, (reader, target) => target.globalAngle = (0, psdReader_1.readInt32)(reader), (writer, target) => (0, psdWriter_1.writeInt32)(writer, target.globalAngle));
7542
7947
  addHandler(1049, target => target.globalAltitude !== undefined, (reader, target) => target.globalAltitude = (0, psdReader_1.readUint32)(reader), (writer, target) => (0, psdWriter_1.writeUint32)(writer, target.globalAltitude));
7543
- addHandler(1011, target => target.printFlags !== undefined, (reader, target) => {
7948
+ addHandler(1011, target => target.printFlags !== undefined, (reader, target, left) => {
7544
7949
  target.printFlags = {
7545
7950
  labels: !!(0, psdReader_1.readUint8)(reader),
7546
7951
  cropMarks: !!(0, psdReader_1.readUint8)(reader),
@@ -7550,7 +7955,7 @@ addHandler(1011, target => target.printFlags !== undefined, (reader, target) =>
7550
7955
  flip: !!(0, psdReader_1.readUint8)(reader),
7551
7956
  interpolate: !!(0, psdReader_1.readUint8)(reader),
7552
7957
  caption: !!(0, psdReader_1.readUint8)(reader),
7553
- printFlags: !!(0, psdReader_1.readUint8)(reader),
7958
+ printFlags: left() ? !!(0, psdReader_1.readUint8)(reader) : false,
7554
7959
  };
7555
7960
  }, (writer, target) => {
7556
7961
  const flags = target.printFlags;
@@ -7676,7 +8081,7 @@ addHandler(1032, target => target.gridAndGuidesInformation !== undefined, (reade
7676
8081
  };
7677
8082
  for (let i = 0; i < count; i++) {
7678
8083
  target.gridAndGuidesInformation.guides.push({
7679
- location: (0, psdReader_1.readUint32)(reader) / 32,
8084
+ location: (0, psdReader_1.readInt32)(reader) / 32,
7680
8085
  direction: (0, psdReader_1.readUint8)(reader) ? 'horizontal' : 'vertical'
7681
8086
  });
7682
8087
  }
@@ -7685,11 +8090,11 @@ addHandler(1032, target => target.gridAndGuidesInformation !== undefined, (reade
7685
8090
  const grid = info.grid || { horizontal: 18 * 32, vertical: 18 * 32 };
7686
8091
  const guides = info.guides || [];
7687
8092
  (0, psdWriter_1.writeUint32)(writer, 1);
7688
- (0, psdWriter_1.writeUint32)(writer, grid.horizontal);
7689
- (0, psdWriter_1.writeUint32)(writer, grid.vertical);
8093
+ (0, psdWriter_1.writeUint32)(writer, Math.round(grid.horizontal));
8094
+ (0, psdWriter_1.writeUint32)(writer, Math.round(grid.vertical));
7690
8095
  (0, psdWriter_1.writeUint32)(writer, guides.length);
7691
8096
  for (const g of guides) {
7692
- (0, psdWriter_1.writeUint32)(writer, g.location * 32);
8097
+ (0, psdWriter_1.writeInt32)(writer, Math.round(g.location * 32));
7693
8098
  (0, psdWriter_1.writeUint8)(writer, g.direction === 'horizontal' ? 1 : 0);
7694
8099
  }
7695
8100
  });
@@ -7705,10 +8110,10 @@ target => target.layerComps !== undefined, (reader, target) => {
7705
8110
  name: item['Nm '],
7706
8111
  capturedInfo: item.capturedInfo,
7707
8112
  });
7708
- if ('comment' in item)
8113
+ if (item.comment !== undefined)
7709
8114
  target.layerComps.list[target.layerComps.list.length - 1].comment = item.comment;
7710
8115
  }
7711
- if ('lastAppliedComp' in desc)
8116
+ if (desc.lastAppliedComp !== undefined)
7712
8117
  target.layerComps.lastApplied = desc.lastAppliedComp;
7713
8118
  }, (writer, target) => {
7714
8119
  const layerComps = target.layerComps;
@@ -7717,13 +8122,13 @@ target => target.layerComps !== undefined, (reader, target) => {
7717
8122
  const t = {};
7718
8123
  t._classID = 'Comp';
7719
8124
  t['Nm '] = item.name;
7720
- if ('comment' in item)
8125
+ if (item.comment !== undefined)
7721
8126
  t.comment = item.comment;
7722
8127
  t.compID = item.id;
7723
8128
  t.capturedInfo = item.capturedInfo;
7724
8129
  desc.list.push(t);
7725
8130
  }
7726
- if ('lastApplied' in layerComps)
8131
+ if (layerComps.lastApplied !== undefined)
7727
8132
  desc.lastAppliedComp = layerComps.lastApplied;
7728
8133
  // console.log('CompList', require('util').inspect(desc, false, 99, true));
7729
8134
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'CompList', desc);
@@ -7765,8 +8170,8 @@ target => target.onionSkins !== undefined, (reader, target) => {
7765
8170
  numBefore: onionSkins.framesBefore,
7766
8171
  numAfter: onionSkins.framesAfter,
7767
8172
  Spcn: onionSkins.frameSpacing,
7768
- minOpacity: (onionSkins.minOpacity * 100) | 0,
7769
- maxOpacity: (onionSkins.maxOpacity * 100) | 0,
8173
+ minOpacity: Math.round(onionSkins.minOpacity * 100),
8174
+ maxOpacity: Math.round(onionSkins.maxOpacity * 100),
7770
8175
  BlnM: Math.max(0, onionSkinsBlendModes.indexOf(onionSkins.blendMode)),
7771
8176
  };
7772
8177
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
@@ -7827,7 +8232,7 @@ target => target.timelineInformation !== undefined, (reader, target) => {
7827
8232
  LCnt: timeline.repeats,
7828
8233
  globalTrackList: (0, descriptor_1.serializeTrackList)(timeline.globalTracks),
7829
8234
  audioClipGroupList: {
7830
- audioClipGroupList: (_a = timeline.audioClipGroups) === null || _a === void 0 ? void 0 : _a.map(a => ({
8235
+ audioClipGroupList: ((_a = timeline.audioClipGroups) !== null && _a !== void 0 ? _a : []).map(a => ({
7831
8236
  groupID: a.id,
7832
8237
  muted: a.muted,
7833
8238
  audioClipList: a.audioClips.map(c => ({
@@ -7924,7 +8329,7 @@ const sliceTypes = ['noImage', 'image'];
7924
8329
  const sliceAlignments = ['default'];
7925
8330
  addHandler(1050, // Slices
7926
8331
  // Slices
7927
- target => target.slices ? target.slices.length : 0, (reader, target) => {
8332
+ target => target.slices ? target.slices.length : 0, (reader, target, leftBytes) => {
7928
8333
  const version = (0, psdReader_1.readUint32)(reader);
7929
8334
  if (version === 6) {
7930
8335
  if (!target.slices)
@@ -7968,16 +8373,23 @@ target => target.slices ? target.slices.length : 0, (reader, target) => {
7968
8373
  backgroundColorType, backgroundColor: { r, g, b, a },
7969
8374
  });
7970
8375
  }
7971
- const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
7972
- desc.slices.forEach(d => {
7973
- const slice = slices.find(s => d.sliceID == s.id);
7974
- if (slice) {
7975
- slice.topOutset = d.topOutset;
7976
- slice.leftOutset = d.leftOutset;
7977
- slice.bottomOutset = d.bottomOutset;
7978
- slice.rightOutset = d.rightOutset;
8376
+ if (leftBytes()) {
8377
+ const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
8378
+ const slicesById = new Map();
8379
+ for (const s of slices) {
8380
+ if (!slicesById.has(s.id))
8381
+ slicesById.set(s.id, s);
7979
8382
  }
7980
- });
8383
+ desc.slices.forEach(d => {
8384
+ const slice = slicesById.get(d.sliceID);
8385
+ if (slice) {
8386
+ slice.topOutset = d.topOutset;
8387
+ slice.leftOutset = d.leftOutset;
8388
+ slice.bottomOutset = d.bottomOutset;
8389
+ slice.rightOutset = d.rightOutset;
8390
+ }
8391
+ });
8392
+ }
7981
8393
  }
7982
8394
  else if (version === 7 || version === 8) {
7983
8395
  const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
@@ -8096,7 +8508,7 @@ addHandler(1036, target => target.thumbnail !== undefined || target.thumbnailRaw
8096
8508
  target.thumbnailRaw = { width, height, data };
8097
8509
  }
8098
8510
  else if (data.byteLength) {
8099
- target.thumbnail = (0, helpers_1.createCanvasFromData)(data);
8511
+ target.thumbnail = (0, helpers_1.createCanvasFromData)(data, reader);
8100
8512
  }
8101
8513
  }, (writer, target) => {
8102
8514
  var _a;
@@ -8175,7 +8587,7 @@ addHandler(1088, target => target.pathSelectionState !== undefined, (reader, tar
8175
8587
  const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
8176
8588
  target.pathSelectionState = desc['null'];
8177
8589
  }, (writer, target) => {
8178
- const desc = { 'null': target.pathSelectionState };
8590
+ const desc = { 'null': (0, descriptor_1.pathSelectionStateToReference)(target.pathSelectionState) };
8179
8591
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
8180
8592
  });
8181
8593
  helpers_1.MOCK_HANDLERS && addHandler(1025, target => target._ir1025 !== undefined, (reader, target, left) => {
@@ -8257,7 +8669,7 @@ target => target.animations !== undefined, (reader, target, left) => {
8257
8669
  FrID: f.id,
8258
8670
  };
8259
8671
  if (f.delay)
8260
- frame.FrDl = (f.delay * 100) | 0;
8672
+ frame.FrDl = Math.round(f.delay * 100);
8261
8673
  frame.FrDs = FrmD.encode(f.dispose);
8262
8674
  // if (i === 0) frame.FrGA = 30; // ???
8263
8675
  desc.FrIn.push(frame);
@@ -8381,6 +8793,7 @@ function writePsdBuffer(psd, options) {
8381
8793
  if (typeof Buffer === 'undefined') {
8382
8794
  throw new Error('Buffer not supported on this platform');
8383
8795
  }
8796
+ // copy, so the buffer doesn't hold on to the unused part of the writer's buffer
8384
8797
  return Buffer.from(writePsdUint8Array(psd, options));
8385
8798
  }
8386
8799
 
@@ -8434,6 +8847,8 @@ const maxResolutionInMP = 100; // Don't decode more than 100 megapixels
8434
8847
  const maxMemoryUsageBytes = 64 * 1024 * 1024; // Don't decode if memory footprint is more than 64MB
8435
8848
  let totalBytesAllocated = 0; // avoid unexpected OOMs from untrusted content.
8436
8849
  function requestMemoryAllocation(increaseAmount) {
8850
+ if (!isFinite(increaseAmount) || increaseAmount < 0)
8851
+ throw new Error(`Invalid memory allocation size (${increaseAmount})`);
8437
8852
  const totalMemoryImpactBytes = totalBytesAllocated + increaseAmount;
8438
8853
  if (totalMemoryImpactBytes > maxMemoryUsageBytes) {
8439
8854
  const exceededAmount = Math.ceil((totalMemoryImpactBytes - maxMemoryUsageBytes) / 1024 / 1024);
@@ -8499,6 +8914,8 @@ function decodeScan(data, offset, frame, components, resetInterval, spectralStar
8499
8914
  return bitsData >>> 7;
8500
8915
  }
8501
8916
  function decodeHuffman(tree) {
8917
+ if (!tree)
8918
+ throw new Error('Missing Huffman table');
8502
8919
  let node = tree;
8503
8920
  while (true) {
8504
8921
  node = node[readBit()];
@@ -8681,6 +9098,8 @@ function decodeScan(data, offset, frame, components, resetInterval, spectralStar
8681
9098
  else {
8682
9099
  mcuExpected = mcusPerLine * frame.mcusPerColumn;
8683
9100
  }
9101
+ if (!isFinite(mcuExpected) || mcuExpected < 0)
9102
+ throw new Error('Invalid number of MCUs');
8684
9103
  if (!resetInterval)
8685
9104
  resetInterval = mcuExpected;
8686
9105
  let h;
@@ -8696,6 +9115,9 @@ function decodeScan(data, offset, frame, components, resetInterval, spectralStar
8696
9115
  for (let n = 0; n < resetInterval; n++) {
8697
9116
  decodeBlock(component, decodeFn, mcu);
8698
9117
  mcu++;
9118
+ // If we've reached our expected MCU's, stop decoding
9119
+ if (mcu === mcuExpected)
9120
+ break;
8699
9121
  }
8700
9122
  }
8701
9123
  else {
@@ -8756,6 +9178,8 @@ function buildComponentData(component) {
8756
9178
  // 988-991.
8757
9179
  function quantizeAndInverse(zz, dataOut, dataIn) {
8758
9180
  const qt = component.quantizationTable;
9181
+ if (!qt)
9182
+ throw new Error('Missing quantization table');
8759
9183
  const p = dataIn;
8760
9184
  // dequant
8761
9185
  for (let i = 0; i < 64; i++) {
@@ -9105,10 +9529,14 @@ function parse(data) {
9105
9529
  throw new Error(`maxResolutionInMP limit exceeded by ${exceededAmount}MP`);
9106
9530
  }
9107
9531
  const componentsCount = data[offset++];
9532
+ if (!componentsCount)
9533
+ throw new Error('SOF: no components in frame');
9108
9534
  for (let i = 0; i < componentsCount; i++) {
9109
9535
  const componentId = data[offset];
9110
9536
  const h = data[offset + 1] >> 4;
9111
9537
  const v = data[offset + 1] & 15;
9538
+ if (h < 1 || h > 4 || v < 1 || v > 4)
9539
+ throw new Error(`SOF: invalid sampling factors (${h}x${v})`);
9112
9540
  const qId = data[offset + 2];
9113
9541
  frame.componentsOrder.push(componentId);
9114
9542
  frame.components[componentId] = {
@@ -9156,11 +9584,16 @@ function parse(data) {
9156
9584
  readUint16(); // Ignore this data since it represents the image height
9157
9585
  break;
9158
9586
  case 0xFFDA: { // SOS (Start of Scan)
9587
+ if (!frame)
9588
+ throw new Error('SOS: scan before frame header (SOF)');
9159
9589
  readUint16(); // skip data length
9160
9590
  const selectorsCount = data[offset++];
9161
9591
  const components = [];
9162
9592
  for (let i = 0; i < selectorsCount; i++) {
9163
- const component = frame.components[data[offset++]];
9593
+ const componentId = data[offset++];
9594
+ const component = frame.components[componentId];
9595
+ if (!component)
9596
+ throw new Error(`SOS: component ${componentId} not found in frame`);
9164
9597
  const tableSpec = data[offset++];
9165
9598
  component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
9166
9599
  component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
@@ -9209,7 +9642,10 @@ function parse(data) {
9209
9642
  for (let i = 0; i < frames.length; i++) {
9210
9643
  const cp = frames[i].components;
9211
9644
  for (let j in cp) { // TODO: don't use `in`
9212
- cp[j].quantizationTable = quantizationTables[cp[j].quantizationIdx];
9645
+ const table = quantizationTables[cp[j].quantizationIdx];
9646
+ if (!table)
9647
+ throw new Error(`Missing quantization table ${cp[j].quantizationIdx}`);
9648
+ cp[j].quantizationTable = table;
9213
9649
  delete cp[j].quantizationIdx; // TODO: why ???
9214
9650
  }
9215
9651
  }
@@ -9265,11 +9701,8 @@ function getData(decoded) {
9265
9701
  break;
9266
9702
  }
9267
9703
  case 3: {
9268
- // The default transform for three components is true
9269
- colorTransform = true;
9270
- // The adobe transform marker overrides any previous setting
9271
- if (decoded.adobe && decoded.adobe.transformCode)
9272
- colorTransform = true;
9704
+ // The default transform for three components is true, the adobe transform marker overrides it
9705
+ colorTransform = decoded.adobe ? !!decoded.adobe.transformCode : true;
9273
9706
  const component1 = decoded.components[0];
9274
9707
  const component2 = decoded.components[1];
9275
9708
  const component3 = decoded.components[2];
@@ -9596,22 +10029,24 @@ function readFixedPoint32(reader) {
9596
10029
  function readFixedPointPath32(reader) {
9597
10030
  return readInt32(reader) / (1 << 24);
9598
10031
  }
10032
+ // NOTE: returned array may alias the reader's underlying buffer, never write into it
9599
10033
  function readBytes(reader, length) {
9600
- const start = reader.view.byteOffset + reader.offset;
10034
+ const start = reader.offset;
10035
+ const viewLength = reader.view.byteLength;
9601
10036
  reader.offset += length;
9602
- if ((start + length) > reader.view.buffer.byteLength) {
10037
+ if ((start + length) > viewLength) {
9603
10038
  // fix for broken PSD files that are missing part of file at the end
9604
10039
  warnOrThrow(reader, 'Reading bytes exceeding buffer length');
9605
10040
  if (length > (100 * 1024 * 1024))
9606
10041
  throw new Error('Reading past end of file'); // limit to 100MB
9607
10042
  const result = new Uint8Array(length);
9608
- const len = Math.min(length, reader.view.byteLength - start);
10043
+ const len = Math.min(length, viewLength - start);
9609
10044
  if (len > 0)
9610
- result.set(new Uint8Array(reader.view.buffer, start, len));
10045
+ result.set(new Uint8Array(reader.view.buffer, reader.view.byteOffset + start, len));
9611
10046
  return result;
9612
10047
  }
9613
10048
  else {
9614
- return new Uint8Array(reader.view.buffer, start, length);
10049
+ return new Uint8Array(reader.view.buffer, reader.view.byteOffset + start, length);
9615
10050
  }
9616
10051
  }
9617
10052
  function readSignature(reader) {
@@ -9636,31 +10071,52 @@ function readUnicodeString(reader) {
9636
10071
  const length = readUint32(reader);
9637
10072
  return readUnicodeStringWithLength(reader, length);
9638
10073
  }
9639
- function readUnicodeStringWithLength(reader, length) {
10074
+ const STRING_CHUNK_SIZE = 0x2000;
10075
+ function checkReadBounds(reader, size) {
10076
+ if (reader.offset < 0 || (reader.offset + size) > reader.view.byteLength) {
10077
+ throw new RangeError('Offset is outside the bounds of the DataView');
10078
+ }
10079
+ }
10080
+ function readUtf16String(reader, length, littleEndian) {
10081
+ if (!(length > 0))
10082
+ return '';
10083
+ checkReadBounds(reader, length * 2);
10084
+ const view = reader.view;
10085
+ const codes = new Uint16Array(Math.min(length, STRING_CHUNK_SIZE));
10086
+ let offset = reader.offset;
9640
10087
  let text = '';
9641
- while (length--) {
9642
- const value = readUint16(reader);
9643
- if (value || length > 0) { // remove trailing \0
9644
- text += String.fromCharCode(value);
10088
+ for (let i = 0; i < length; i += STRING_CHUNK_SIZE) {
10089
+ const count = Math.min(STRING_CHUNK_SIZE, length - i);
10090
+ for (let j = 0; j < count; j++, offset += 2) {
10091
+ codes[j] = view.getUint16(offset, littleEndian);
9645
10092
  }
10093
+ text += String.fromCharCode.apply(null, (count === codes.length ? codes : codes.subarray(0, count)));
9646
10094
  }
10095
+ reader.offset = offset;
10096
+ // remove trailing \0
10097
+ if (text.charCodeAt(text.length - 1) === 0)
10098
+ text = text.substring(0, text.length - 1);
9647
10099
  return text;
9648
10100
  }
9649
- function readUnicodeStringWithLengthLE(reader, length) {
10101
+ function bytesToString(bytes) {
9650
10102
  let text = '';
9651
- while (length--) {
9652
- const value = readUint16LE(reader);
9653
- if (value || length > 0) { // remove trailing \0
9654
- text += String.fromCharCode(value);
9655
- }
10103
+ for (let i = 0; i < bytes.length; i += STRING_CHUNK_SIZE) {
10104
+ text += String.fromCharCode.apply(null, bytes.subarray(i, i + STRING_CHUNK_SIZE));
9656
10105
  }
9657
10106
  return text;
9658
10107
  }
10108
+ function readUnicodeStringWithLength(reader, length) {
10109
+ return readUtf16String(reader, length, false);
10110
+ }
10111
+ function readUnicodeStringWithLengthLE(reader, length) {
10112
+ return readUtf16String(reader, length, true);
10113
+ }
9659
10114
  function readAsciiString(reader, length) {
9660
- let text = '';
9661
- while (length--) {
9662
- text += String.fromCharCode(readUint8(reader));
9663
- }
10115
+ if (!(length > 0))
10116
+ return '';
10117
+ checkReadBounds(reader, length);
10118
+ const text = bytesToString(new Uint8Array(reader.view.buffer, reader.view.byteOffset + reader.offset, length));
10119
+ reader.offset += length;
9664
10120
  return text;
9665
10121
  }
9666
10122
  function skipBytes(reader, count) {
@@ -9674,12 +10130,7 @@ function checkSignature(reader, a, b) {
9674
10130
  }
9675
10131
  }
9676
10132
  function readShortString(reader, length) {
9677
- const buffer = readBytes(reader, length);
9678
- let result = '';
9679
- for (let i = 0; i < buffer.length; i++) {
9680
- result += String.fromCharCode(buffer[i]);
9681
- }
9682
- return result;
10133
+ return bytesToString(readBytes(reader, length));
9683
10134
  }
9684
10135
  function isValidSignature(sig) {
9685
10136
  return sig === '8BIM' || sig === 'MeSa' || sig === 'AgHg' || sig === 'PHUT' || sig === 'DCSR';
@@ -9700,7 +10151,7 @@ function readPsd(reader, readOptions = {}) {
9700
10151
  const maxSize = version === 1 ? 30000 : 300000;
9701
10152
  if (width > maxSize || height > maxSize)
9702
10153
  throw new Error(`Invalid size: ${width}x${height}`);
9703
- if (channels > 16)
10154
+ if (channels < 1 || channels > 56)
9704
10155
  throw new Error(`Invalid channel count: ${channels}`);
9705
10156
  if (![1, 8, 16, 32].includes(bitsPerChannel))
9706
10157
  throw new Error(`Invalid bitsPerChannel: ${bitsPerChannel}`);
@@ -9802,7 +10253,10 @@ function readPsd(reader, readOptions = {}) {
9802
10253
  const skipComposite = reader.skipCompositeImageData && (reader.skipLayerImageData || hasChildren);
9803
10254
  if (!skipComposite) {
9804
10255
  if (reader.useRawData) {
9805
- psd.rawCompositeData = new Uint8Array(reader.view.buffer, reader.view.byteOffset + reader.offset);
10256
+ const rawOffset = Math.min(reader.offset, reader.view.byteLength);
10257
+ const rawCompositeData = new Uint8Array(reader.view.buffer, reader.view.byteOffset + rawOffset, reader.view.byteLength - rawOffset);
10258
+ psd.rawCompositeData = rawCompositeData;
10259
+ psd.rawCompositeDataInfo = { large: reader.large, globalAlpha: reader.globalAlpha };
9806
10260
  }
9807
10261
  else {
9808
10262
  const imageData = readImageData(reader, psd);
@@ -9857,7 +10311,9 @@ function readLayerInfo(reader, psd, imageResources) {
9857
10311
  stack.push(l);
9858
10312
  }
9859
10313
  else if (type === 3 /* SectionDividerType.BoundingSectionDivider */) {
9860
- stack.pop();
10314
+ // ignore unmatched section dividers, never pop the root
10315
+ if (stack.length > 1)
10316
+ stack.pop();
9861
10317
  // this was workaround because I didn't know what `lsdk` section was, now it's probably not needed anymore
9862
10318
  // } else if (l.name === '</Layer group>' && !l.sectionDivider && !l.top && !l.left && !l.bottom && !l.right) {
9863
10319
  // // sometimes layer group terminator doesn't have sectionDivider, so we just guess here (PS bug ?)
@@ -9943,7 +10399,7 @@ function readLayerMaskData(reader, layer) {
9943
10399
  mask.positionRelativeToLayer = (flags & 1 /* LayerMaskFlags.PositionRelativeToLayer */) !== 0;
9944
10400
  mask.disabled = (flags & 2 /* LayerMaskFlags.LayerMaskDisabled */) !== 0;
9945
10401
  mask.fromVectorData = (flags & 8 /* LayerMaskFlags.LayerMaskFromRenderingOtherData */) !== 0;
9946
- if (left() >= 18) {
10402
+ if (hasRealMaskData(reader, flags, left())) {
9947
10403
  const realMask = {};
9948
10404
  layer.realMask = realMask;
9949
10405
  const realFlags = readUint8(reader);
@@ -9972,6 +10428,43 @@ function readLayerMaskData(reader, layer) {
9972
10428
  skipBytes(reader, left());
9973
10429
  });
9974
10430
  }
10431
+ function maskParamsSize(params) {
10432
+ return 1 +
10433
+ ((params & 1 /* MaskParams.UserMaskDensity */) ? 1 : 0) +
10434
+ ((params & 2 /* MaskParams.UserMaskFeather */) ? 8 : 0) +
10435
+ ((params & 4 /* MaskParams.VectorMaskDensity */) ? 1 : 0) +
10436
+ ((params & 8 /* MaskParams.VectorMaskFeather */) ? 8 : 0);
10437
+ }
10438
+ // checks if data at offset is mask parameters followed by up to 3 bytes of zero padding, ending exactly at offset + left
10439
+ function isMaskParamsLayout(view, offset, left) {
10440
+ if (left < 1)
10441
+ return false;
10442
+ const params = view.getUint8(offset);
10443
+ if (params === 0 || (params & ~0x0f))
10444
+ return false; // only 4 parameter flags exist
10445
+ const size = maskParamsSize(params);
10446
+ if (left < size || left - size > 3)
10447
+ return false;
10448
+ for (let i = size; i < left; i++) {
10449
+ if (view.getUint8(offset + i) !== 0)
10450
+ return false;
10451
+ }
10452
+ return true;
10453
+ }
10454
+ // real mask data (18 bytes) is followed by mask parameters (if flag is set) and padding
10455
+ function hasRealMaskData(reader, flags, left) {
10456
+ if (left < 18)
10457
+ return false;
10458
+ if (!(flags & 16 /* LayerMaskFlags.MaskHasParametersAppliedToIt */))
10459
+ return true;
10460
+ const { view, offset } = reader;
10461
+ if (isMaskParamsLayout(view, offset, left))
10462
+ return false;
10463
+ if (isMaskParamsLayout(view, offset + 18, left - 18))
10464
+ return true;
10465
+ // unknown layout, assume real mask if there's enough data for it (and mask parameters)
10466
+ return left === 18 || left - 18 >= maskParamsSize(view.getUint8(offset + 18));
10467
+ }
9975
10468
  function readBlendingRange(reader) {
9976
10469
  return [readUint8(reader), readUint8(reader), readUint8(reader), readUint8(reader)];
9977
10470
  }
@@ -10038,8 +10531,12 @@ function getCompositeImageData(psd) {
10038
10531
  if (!data)
10039
10532
  return undefined;
10040
10533
  const reader = createReader(data.buffer, data.byteOffset, data.byteLength);
10041
- const imageData = readImageData(reader, psd);
10042
- return imageData;
10534
+ const info = psd.rawCompositeDataInfo;
10535
+ if (info) {
10536
+ reader.large = info.large;
10537
+ reader.globalAlpha = info.globalAlpha;
10538
+ }
10539
+ return readImageData(reader, psd);
10043
10540
  }
10044
10541
  function getCompositeCanvas(psd) {
10045
10542
  return imageDataToCanvasSafe(getCompositeImageData(psd));
@@ -10081,18 +10578,18 @@ function decodeLayerPixels(layer, useImageData) {
10081
10578
  function decodeLayerImageData(layer, options) {
10082
10579
  var _a, _b, _c;
10083
10580
  let { throwForMissingFeatures, useImageData } = options;
10084
- const imageData = getDataFromLayer(layer, LayerDataType.Layer, throwForMissingFeatures, options.totalMemoryLimit);
10581
+ const imageData = getDataFromLayer(layer, LayerDataType.Layer, throwForMissingFeatures, options.totalMemoryLimit, options);
10085
10582
  setImageDataOrCanvas(layer, imageData, useImageData);
10086
10583
  if (options.totalMemoryLimit !== undefined)
10087
10584
  options.totalMemoryLimit -= (_a = imageData === null || imageData === void 0 ? void 0 : imageData.data.byteLength) !== null && _a !== void 0 ? _a : 0;
10088
10585
  if (layer.mask) {
10089
- const maskData = getDataFromLayer(layer, LayerDataType.Mask, throwForMissingFeatures, options.totalMemoryLimit);
10586
+ const maskData = getDataFromLayer(layer, LayerDataType.Mask, throwForMissingFeatures, options.totalMemoryLimit, options);
10090
10587
  setImageDataOrCanvas(layer.mask, maskData, useImageData);
10091
10588
  if (options.totalMemoryLimit !== undefined)
10092
10589
  options.totalMemoryLimit -= (_b = maskData === null || maskData === void 0 ? void 0 : maskData.data.byteLength) !== null && _b !== void 0 ? _b : 0;
10093
10590
  }
10094
10591
  if (layer.realMask) {
10095
- const maskData = getDataFromLayer(layer, LayerDataType.RealMask, throwForMissingFeatures, options.totalMemoryLimit);
10592
+ const maskData = getDataFromLayer(layer, LayerDataType.RealMask, throwForMissingFeatures, options.totalMemoryLimit, options);
10096
10593
  setImageDataOrCanvas(layer.realMask, maskData, useImageData);
10097
10594
  if (options.totalMemoryLimit !== undefined)
10098
10595
  options.totalMemoryLimit -= (_c = maskData === null || maskData === void 0 ? void 0 : maskData.data.byteLength) !== null && _c !== void 0 ? _c : 0;
@@ -10105,7 +10602,8 @@ var LayerDataType;
10105
10602
  LayerDataType[LayerDataType["Mask"] = 1] = "Mask";
10106
10603
  LayerDataType[LayerDataType["RealMask"] = 2] = "RealMask";
10107
10604
  })(LayerDataType || (LayerDataType = {}));
10108
- function getDataFromLayer(layer, read, throwForMissingFeatures, memoryLimit) {
10605
+ function getDataFromLayer(layer, read, throwForMissingFeatures, memoryLimit, logOptions) {
10606
+ var _a;
10109
10607
  if (!layer.rawData)
10110
10608
  return undefined;
10111
10609
  const { colorMode, bitsPerChannel, channels, large } = layer.rawData;
@@ -10118,7 +10616,7 @@ function getDataFromLayer(layer, read, throwForMissingFeatures, memoryLimit) {
10118
10616
  if (layerWidth && layerHeight && read === LayerDataType.Layer) {
10119
10617
  if (cmyk) {
10120
10618
  if (bitsPerChannel !== 8)
10121
- throw new Error('bitsPerChannel Not supproted');
10619
+ throw new Error('bitsPerChannel not supported');
10122
10620
  imageData = { width: layerWidth, height: layerHeight, data: new Uint8ClampedArray(layerWidth * layerHeight * 5) };
10123
10621
  }
10124
10622
  else {
@@ -10133,6 +10631,11 @@ function getDataFromLayer(layer, read, throwForMissingFeatures, memoryLimit) {
10133
10631
  if (!data)
10134
10632
  continue;
10135
10633
  const dataReader = createReader(data.buffer, data.byteOffset, data.byteLength);
10634
+ dataReader.debug = !!(logOptions === null || logOptions === void 0 ? void 0 : logOptions.debug);
10635
+ if (logOptions === null || logOptions === void 0 ? void 0 : logOptions.log)
10636
+ dataReader.log = logOptions.log;
10637
+ if (memoryLimit !== undefined)
10638
+ dataReader.totalMemoryLimit = Math.max(0, memoryLimit - ((_a = imageData === null || imageData === void 0 ? void 0 : imageData.data.byteLength) !== null && _a !== void 0 ? _a : 0));
10136
10639
  if (id === -2 /* ChannelID.UserMask */ || id === -3 /* ChannelID.RealUserMask */) {
10137
10640
  if (id === -2 /* ChannelID.UserMask */ && read !== LayerDataType.Mask)
10138
10641
  continue;
@@ -10145,6 +10648,8 @@ function getDataFromLayer(layer, read, throwForMissingFeatures, memoryLimit) {
10145
10648
  const maskHeight = Math.max(0, (mask.bottom || 0) - (mask.top || 0));
10146
10649
  if (maskWidth && maskHeight) {
10147
10650
  maskData = createImageDataBitDepth(maskWidth, maskHeight, bitsPerChannel, 4, memoryLimit);
10651
+ if (memoryLimit !== undefined)
10652
+ dataReader.totalMemoryLimit = Math.max(0, dataReader.totalMemoryLimit - maskData.data.byteLength);
10148
10653
  readData(dataReader, data.byteLength, maskData, compression, maskWidth, maskHeight, bitsPerChannel, 0, large, 4);
10149
10654
  if (helpers_1.RAW_IMAGE_DATA) { // TODO: use layer.rawData instead
10150
10655
  if (id === -2 /* ChannelID.UserMask */) {
@@ -10176,15 +10681,14 @@ function getDataFromLayer(layer, read, throwForMissingFeatures, memoryLimit) {
10176
10681
  layer.imageDataRawCompression[id] = compression;
10177
10682
  layer.imageDataRaw[id] = data;
10178
10683
  }
10179
- if (targetData && colorMode === 1 /* ColorMode.Grayscale */) {
10180
- setupGrayscale(targetData);
10181
- }
10182
10684
  }
10183
10685
  if (id === -1 /* ChannelID.Transparency */) {
10184
10686
  initializedAlpha = true;
10185
10687
  }
10186
10688
  }
10187
10689
  if (imageData) {
10690
+ if (colorMode === 1 /* ColorMode.Grayscale */)
10691
+ setupGrayscale(imageData);
10188
10692
  if (!initializedAlpha)
10189
10693
  resetAlpha(imageData, cmyk);
10190
10694
  if (cmyk) {
@@ -10200,7 +10704,7 @@ function readData(reader, length, pixels, compression, width, height, bitDepth,
10200
10704
  return;
10201
10705
  if (compression === 0 /* Compression.RawData */) {
10202
10706
  if (length !== (width * height * Math.floor(bitDepth / 8))) {
10203
- reader.log(`Invalid length (${length}, ${width * height * Math.floor(bitDepth / 8)})`);
10707
+ warnOrThrow(reader, `Invalid length (${length}, ${width * height * Math.floor(bitDepth / 8)})`);
10204
10708
  }
10205
10709
  const data = readBytes(reader, length);
10206
10710
  readDataRaw(data, pixels, bitDepth, step, offset);
@@ -10211,11 +10715,11 @@ function readData(reader, length, pixels, compression, width, height, bitDepth,
10211
10715
  }
10212
10716
  else if (compression === 2 /* Compression.ZipWithoutPrediction */) {
10213
10717
  const data = readBytes(reader, length);
10214
- readDataZip(data, pixels, width, height, bitDepth, step, offset, false);
10718
+ readDataZip(data, pixels, width, height, bitDepth, step, offset, false, reader);
10215
10719
  }
10216
10720
  else if (compression === 3 /* Compression.ZipWithPrediction */) {
10217
10721
  const data = readBytes(reader, length);
10218
- readDataZip(data, pixels, width, height, bitDepth, step, offset, true);
10722
+ readDataZip(data, pixels, width, height, bitDepth, step, offset, true, reader);
10219
10723
  }
10220
10724
  else {
10221
10725
  throw new Error(`Invalid Compression type: ${compression}`);
@@ -10230,7 +10734,7 @@ function readGlobalLayerMaskInfo(reader) {
10230
10734
  const colorSpace2 = readUint16(reader);
10231
10735
  const colorSpace3 = readUint16(reader);
10232
10736
  const colorSpace4 = readUint16(reader);
10233
- const opacity = readUint16(reader) / 0xff;
10737
+ const opacity = readUint16(reader) / 100; // 0 - 100
10234
10738
  const kind = readUint8(reader);
10235
10739
  skipBytes(reader, left()); // 3 bytes of padding ?
10236
10740
  return { overlayColorSpace, colorSpace1, colorSpace2, colorSpace3, colorSpace4, opacity, kind };
@@ -10310,11 +10814,12 @@ function readImageData(reader, psd) {
10310
10814
  var _a;
10311
10815
  const compression = readUint16(reader);
10312
10816
  const bitsPerChannel = (_a = psd.bitsPerChannel) !== null && _a !== void 0 ? _a : 8;
10817
+ const { width, height } = psd;
10313
10818
  if (exports.supportedColorModes.indexOf(psd.colorMode) === -1)
10314
10819
  throw new Error(`Color mode not supported: ${psd.colorMode}`);
10315
10820
  if (compression !== 0 /* Compression.RawData */ && compression !== 1 /* Compression.RleCompressed */)
10316
10821
  throw new Error(`Compression type not supported: ${compression}`);
10317
- const imageData = createImageDataBitDepth(psd.width, psd.height, bitsPerChannel, 4, reader.totalMemoryLimit);
10822
+ const imageData = createImageDataBitDepth(width, height, bitsPerChannel, 4, reader.totalMemoryLimit);
10318
10823
  if (reader.totalMemoryLimit !== undefined)
10319
10824
  reader.totalMemoryLimit -= imageData.data.byteLength;
10320
10825
  (0, helpers_1.resetImageData)(imageData);
@@ -10322,46 +10827,26 @@ function readImageData(reader, psd) {
10322
10827
  case 0 /* ColorMode.Bitmap */: {
10323
10828
  if (bitsPerChannel !== 1)
10324
10829
  throw new Error('Invalid bitsPerChannel for bitmap color mode');
10830
+ const rowBytes = Math.ceil(width / 8);
10325
10831
  let bytes;
10326
10832
  if (compression === 0 /* Compression.RawData */) {
10327
- bytes = readBytes(reader, Math.ceil(psd.width / 8) * psd.height);
10328
- }
10329
- else if (compression === 1 /* Compression.RleCompressed */) {
10330
- bytes = new Uint8Array(psd.width * psd.height);
10331
- readDataRLE(reader, { data: bytes, width: psd.width, height: psd.height }, psd.width, psd.height, 8, 1, [0], reader.large);
10833
+ bytes = readBytes(reader, rowBytes * height);
10332
10834
  }
10333
10835
  else {
10334
- throw new Error(`Compression not supported: ${compression}`);
10836
+ bytes = new Uint8Array(rowBytes * height);
10837
+ readDataRLE(reader, { data: bytes, width: rowBytes, height }, rowBytes, height, 8, 1, [0], reader.large);
10335
10838
  }
10336
- (0, helpers_1.decodeBitmap)(bytes, imageData.data, psd.width, psd.height);
10839
+ (0, helpers_1.decodeBitmap)(bytes, imageData.data, width, height);
10337
10840
  break;
10338
10841
  }
10339
10842
  case 3 /* ColorMode.RGB */:
10340
10843
  case 1 /* ColorMode.Grayscale */: {
10341
- const channels = psd.colorMode === 1 /* ColorMode.Grayscale */ ? [0] : [0, 1, 2];
10342
- if (psd.channels && psd.channels > 3) {
10343
- for (let i = 3; i < psd.channels; i++) {
10344
- // TODO: store these channels in additional image data
10345
- channels.push(i);
10346
- }
10347
- }
10348
- else if (reader.globalAlpha) {
10349
- channels.push(3);
10350
- }
10351
- if (compression === 0 /* Compression.RawData */) {
10352
- for (let i = 0; i < channels.length; i++) {
10353
- const data = readBytes(reader, psd.width * psd.height * Math.floor(bitsPerChannel / 8));
10354
- readDataRaw(data, imageData, bitsPerChannel, 4, channels[i]);
10355
- }
10356
- }
10357
- else if (compression === 1 /* Compression.RleCompressed */) {
10358
- const start = reader.offset;
10359
- readDataRLE(reader, imageData, psd.width, psd.height, bitsPerChannel, 4, channels, reader.large);
10360
- if (helpers_1.RAW_IMAGE_DATA)
10361
- psd.imageDataRaw = new Uint8Array(reader.view.buffer, reader.view.byteOffset + start, reader.offset - start);
10362
- }
10363
- else {
10364
- throw new Error(`Compression not supported: ${compression}`);
10844
+ const colorChannels = psd.colorMode === 1 /* ColorMode.Grayscale */ ? 1 : 3;
10845
+ const offsets = compositeChannelOffsets(reader, psd, colorChannels, 3);
10846
+ const start = reader.offset;
10847
+ readCompositeChannels(reader, compression, imageData, bitsPerChannel, 4, offsets);
10848
+ if (helpers_1.RAW_IMAGE_DATA && compression === 1 /* Compression.RleCompressed */) {
10849
+ psd.imageDataRaw = new Uint8Array(reader.view.buffer, reader.view.byteOffset + start, reader.offset - start);
10365
10850
  }
10366
10851
  if (psd.colorMode === 1 /* ColorMode.Grayscale */) {
10367
10852
  setupGrayscale(imageData);
@@ -10370,57 +10855,25 @@ function readImageData(reader, psd) {
10370
10855
  }
10371
10856
  case 2 /* ColorMode.Indexed */: {
10372
10857
  if (bitsPerChannel !== 8)
10373
- throw new Error('bitsPerChannel Not supproted');
10374
- if (psd.channels !== 1)
10375
- throw new Error('Invalid channel count');
10858
+ throw new Error('bitsPerChannel not supported');
10376
10859
  if (!psd.palette)
10377
10860
  throw new Error('Missing color palette');
10378
- if (compression === 0 /* Compression.RawData */) {
10379
- throw new Error(`Compression not supported: ${compression}`);
10380
- }
10381
- else if (compression === 1 /* Compression.RleCompressed */) {
10382
- const indexedImageData = {
10383
- width: imageData.width,
10384
- height: imageData.height,
10385
- data: new Uint8Array(imageData.width * imageData.height),
10386
- };
10387
- readDataRLE(reader, indexedImageData, psd.width, psd.height, bitsPerChannel, 1, [0], reader.large);
10388
- indexedToRgb(indexedImageData, imageData, psd.palette);
10389
- }
10390
- else {
10391
- throw new Error(`Compression not supported: ${compression}`);
10392
- }
10861
+ const offsets = compositeChannelOffsets(reader, psd, 1, -1);
10862
+ const indexedImageData = { width, height, data: new Uint8Array(width * height) };
10863
+ readCompositeChannels(reader, compression, indexedImageData, 8, 1, offsets);
10864
+ indexedToRgb(indexedImageData, imageData, psd.palette);
10393
10865
  break;
10394
10866
  }
10395
10867
  case 4 /* ColorMode.CMYK */: {
10396
10868
  if (bitsPerChannel !== 8)
10397
- throw new Error('bitsPerChannel Not supproted');
10398
- if (psd.channels !== 4)
10399
- throw new Error(`Invalid channel count`);
10400
- const channels = [0, 1, 2, 3];
10401
- if (reader.globalAlpha)
10402
- channels.push(4);
10403
- if (compression === 0 /* Compression.RawData */) {
10404
- throw new Error(`Compression not supported: ${compression}`);
10405
- // TODO: ...
10406
- // for (let i = 0; i < channels.length; i++) {
10407
- // readDataRaw(reader, imageData, channels[i], psd.width, psd.height);
10408
- // }
10409
- }
10410
- else if (compression === 1 /* Compression.RleCompressed */) {
10411
- const cmykImageData = {
10412
- width: imageData.width,
10413
- height: imageData.height,
10414
- data: new Uint8Array(imageData.width * imageData.height * 5),
10415
- };
10416
- const start = reader.offset;
10417
- readDataRLE(reader, cmykImageData, psd.width, psd.height, bitsPerChannel, 5, channels, reader.large);
10418
- cmykToRgb(cmykImageData, imageData, true);
10419
- if (helpers_1.RAW_IMAGE_DATA)
10420
- psd.imageDataRaw = new Uint8Array(reader.view.buffer, reader.view.byteOffset + start, reader.offset - start);
10421
- }
10422
- else {
10423
- throw new Error(`Compression not supported: ${compression}`);
10869
+ throw new Error('bitsPerChannel not supported');
10870
+ const offsets = compositeChannelOffsets(reader, psd, 4, 4);
10871
+ const cmykImageData = { width, height, data: new Uint8Array(width * height * 5) };
10872
+ const start = reader.offset;
10873
+ readCompositeChannels(reader, compression, cmykImageData, 8, 5, offsets);
10874
+ cmykToRgb(cmykImageData, imageData, true);
10875
+ if (helpers_1.RAW_IMAGE_DATA && compression === 1 /* Compression.RleCompressed */) {
10876
+ psd.imageDataRaw = new Uint8Array(reader.view.buffer, reader.view.byteOffset + start, reader.offset - start);
10424
10877
  }
10425
10878
  break;
10426
10879
  }
@@ -10428,23 +10881,98 @@ function readImageData(reader, psd) {
10428
10881
  }
10429
10882
  // remove weird white matte
10430
10883
  if (reader.globalAlpha) {
10431
- if (psd.bitsPerChannel !== 8)
10432
- throw new Error('bitsPerChannel Not supproted');
10433
- const p = imageData.data;
10434
- const size = imageData.width * imageData.height * 4;
10884
+ removeWhiteMatte(imageData);
10885
+ }
10886
+ return imageData;
10887
+ }
10888
+ // returns target offset for each of the composite image channels stored in the file, -1 for channels that are skipped
10889
+ function compositeChannelOffsets(reader, psd, colorChannels, alphaOffset) {
10890
+ var _a, _b, _c, _d;
10891
+ const channelCount = (_a = psd.channels) !== null && _a !== void 0 ? _a : (colorChannels + (reader.globalAlpha ? 1 : 0));
10892
+ if (channelCount < colorChannels)
10893
+ throw new Error(`Invalid channel count: ${channelCount}`);
10894
+ // First extra channel is transparency if document has global alpha (negative layer count). Some non-Photoshop
10895
+ // applications write transparency channel without setting global alpha, in that case extra channel is not
10896
+ // listed in alpha channel names (Photoshop names all user alpha channels / saved selections).
10897
+ const namedChannels = (_d = (_c = (_b = psd.imageResources) === null || _b === void 0 ? void 0 : _b.alphaChannelNames) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
10898
+ const hasTransparency = reader.globalAlpha || (channelCount - colorChannels) > namedChannels;
10899
+ const offsets = [];
10900
+ for (let i = 0; i < channelCount; i++) {
10901
+ if (i < colorChannels) {
10902
+ offsets.push(i);
10903
+ }
10904
+ else if (i === colorChannels && hasTransparency && alphaOffset >= 0) {
10905
+ offsets.push(alphaOffset);
10906
+ }
10907
+ else {
10908
+ // TODO: store these channels (alpha channels / saved selections, spot colors) in additional image data
10909
+ offsets.push(-1);
10910
+ }
10911
+ }
10912
+ return offsets;
10913
+ }
10914
+ function readCompositeChannels(reader, compression, pixelData, bitsPerChannel, step, offsets) {
10915
+ if (compression === 0 /* Compression.RawData */) {
10916
+ const channelSize = pixelData.width * pixelData.height * bytesPerValue(bitsPerChannel);
10917
+ for (const offset of offsets) {
10918
+ if (offset < 0) {
10919
+ skipBytes(reader, channelSize);
10920
+ }
10921
+ else {
10922
+ readDataRaw(readBytes(reader, channelSize), pixelData, bitsPerChannel, step, offset);
10923
+ }
10924
+ }
10925
+ }
10926
+ else if (compression === 1 /* Compression.RleCompressed */) {
10927
+ readDataRLE(reader, pixelData, pixelData.width, pixelData.height, bitsPerChannel, step, offsets, reader.large);
10928
+ }
10929
+ else {
10930
+ throw new Error(`Compression not supported: ${compression}`);
10931
+ }
10932
+ }
10933
+ // un-premultiplies colors from white matte, used for composite image of documents with global alpha
10934
+ function removeWhiteMatte({ data, width, height }) {
10935
+ const size = width * height * 4;
10936
+ if (data instanceof Float32Array) {
10937
+ for (let i = 0; i < size; i += 4) {
10938
+ const a = data[i + 3];
10939
+ if (a > 0 && a < 1) {
10940
+ const ra = 1 / a;
10941
+ const invA = 1 - ra;
10942
+ for (let j = 0; j < 3; j++) {
10943
+ const v = data[i + j] * ra + invA;
10944
+ data[i + j] = v < 0 ? 0 : v;
10945
+ }
10946
+ }
10947
+ }
10948
+ }
10949
+ else if (data instanceof Uint16Array) {
10435
10950
  for (let i = 0; i < size; i += 4) {
10436
- const pa = p[i + 3];
10951
+ const pa = data[i + 3];
10952
+ if (pa !== 0 && pa !== 0xffff) {
10953
+ const ra = 0xffff / pa;
10954
+ const invA = 0xffff * (1 - ra);
10955
+ for (let j = 0; j < 3; j++) {
10956
+ const v = Math.round(data[i + j] * ra + invA);
10957
+ data[i + j] = v < 0 ? 0 : (v > 0xffff ? 0xffff : v);
10958
+ }
10959
+ }
10960
+ }
10961
+ }
10962
+ else {
10963
+ // Uint8ClampedArray clamps and rounds values on assignment
10964
+ for (let i = 0; i < size; i += 4) {
10965
+ const pa = data[i + 3];
10437
10966
  if (pa != 0 && pa != 255) {
10438
10967
  const a = pa / 255;
10439
10968
  const ra = 1 / a;
10440
10969
  const invA = 255 * (1 - ra);
10441
- p[i + 0] = p[i + 0] * ra + invA;
10442
- p[i + 1] = p[i + 1] * ra + invA;
10443
- p[i + 2] = p[i + 2] * ra + invA;
10970
+ data[i + 0] = data[i + 0] * ra + invA;
10971
+ data[i + 1] = data[i + 1] * ra + invA;
10972
+ data[i + 2] = data[i + 2] * ra + invA;
10444
10973
  }
10445
10974
  }
10446
10975
  }
10447
- return imageData;
10448
10976
  }
10449
10977
  function cmykToRgb(cmyk, rgb, reverseAlpha) {
10450
10978
  const size = rgb.width * rgb.height * 4;
@@ -10483,175 +11011,267 @@ function indexedToRgb(indexed, rgb, palette) {
10483
11011
  dstData[dst + 3] = 255;
10484
11012
  }
10485
11013
  }
10486
- function verifyCompatible(a, b) {
10487
- if ((a.byteLength / a.length) !== (b.byteLength / b.length)) {
10488
- throw new Error('Invalid array types');
11014
+ // number of bytes used to store single channel value, 1-bit data is handled as bytes
11015
+ function bytesPerValue(bitDepth) {
11016
+ switch (bitDepth) {
11017
+ case 1:
11018
+ case 8: return 1;
11019
+ case 16: return 2;
11020
+ case 32: return 4;
11021
+ default: throw new Error(`Invalid bitDepth (${bitDepth})`);
10489
11022
  }
10490
11023
  }
10491
- function bytesToArray(bytes, bitDepth) {
10492
- if (bitDepth === 8) {
10493
- return bytes;
11024
+ function verifyArrayType(data, bytesPerValue) {
11025
+ if (data.BYTES_PER_ELEMENT !== bytesPerValue) {
11026
+ throw new Error('Invalid array types');
10494
11027
  }
10495
- else if (bitDepth === 16) {
10496
- // PSD files store 16-bit channel data in big-endian byte order.
10497
- // Swap each pair of bytes so that Uint16Array (native-endian) reads the correct values.
10498
- for (let i = 0; i < bytes.byteLength; i += 2) {
10499
- const tmp = bytes[i];
10500
- bytes[i] = bytes[i + 1];
10501
- bytes[i + 1] = tmp;
10502
- }
10503
- if (bytes.byteOffset % 2) {
10504
- const result = new Uint16Array(bytes.byteLength / 2);
10505
- new Uint8Array(result.buffer, result.byteOffset, result.byteLength).set(bytes);
10506
- return result;
10507
- }
10508
- else {
10509
- return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);
11028
+ }
11029
+ // NOTE: `buffer` may alias input file data, it must not be modified here
11030
+ function readDataRaw(buffer, pixelData, bitDepth, step, offset) {
11031
+ const bpv = bytesPerValue(bitDepth);
11032
+ if (!pixelData || offset < 0 || offset >= step)
11033
+ return;
11034
+ const data = pixelData.data;
11035
+ verifyArrayType(data, bpv);
11036
+ const size = Math.min(pixelData.width * pixelData.height, Math.floor(buffer.byteLength / bpv)) | 0;
11037
+ if (bpv === 1) {
11038
+ for (let i = 0, p = offset | 0; i < size; i++, p = (p + step) | 0) {
11039
+ data[p] = buffer[i];
10510
11040
  }
10511
11041
  }
10512
- else if (bitDepth === 32) {
10513
- if (bytes.byteOffset % 4) {
10514
- const result = new Float32Array(bytes.byteLength / 4);
10515
- new Uint8Array(result.buffer, result.byteOffset, result.byteLength).set(bytes);
10516
- return result;
10517
- }
10518
- else {
10519
- return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
11042
+ else if (bpv === 2) {
11043
+ for (let i = 0, j = 0, p = offset | 0; i < size; i++, j += 2, p = (p + step) | 0) {
11044
+ data[p] = (buffer[j] << 8) | buffer[j + 1];
10520
11045
  }
10521
11046
  }
10522
11047
  else {
10523
- throw new Error(`Invalid bitDepth (${bitDepth})`);
10524
- }
10525
- }
10526
- function copyChannelToPixelData(pixelData, channel, offset, step) {
10527
- verifyCompatible(pixelData.data, channel);
10528
- const size = pixelData.width * pixelData.height;
10529
- const data = pixelData.data;
10530
- for (let i = 0, p = offset | 0; i < size; i++, p = (p + step) | 0) {
10531
- data[p] = channel[i];
10532
- }
10533
- }
10534
- function readDataRaw(buffer, pixelData, bitDepth, step, offset) {
10535
- if (bitDepth == 32) {
10536
- for (let i = 0; i < buffer.byteLength; i += 4) {
10537
- const a = buffer[i + 0];
10538
- const b = buffer[i + 1];
10539
- const c = buffer[i + 2];
10540
- const d = buffer[i + 3];
10541
- buffer[i + 0] = d;
10542
- buffer[i + 1] = c;
10543
- buffer[i + 2] = b;
10544
- buffer[i + 3] = a;
11048
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
11049
+ for (let i = 0, j = 0, p = offset | 0; i < size; i++, j += 4, p = (p + step) | 0) {
11050
+ data[p] = view.getFloat32(j, false);
10545
11051
  }
10546
11052
  }
10547
- const array = bytesToArray(buffer, bitDepth);
10548
- if (pixelData && offset < step) {
10549
- copyChannelToPixelData(pixelData, array, offset, step);
10550
- }
10551
11053
  }
10552
- function decodePredicted(data, width, height, mod) {
11054
+ function decodePredicted(data, width, height) {
10553
11055
  for (let y = 0; y < height; y++) {
10554
11056
  const offset = y * width;
10555
11057
  for (let x = 1, o = offset + 1; x < width; x++, o++) {
10556
- data[o] = (data[o - 1] + data[o]) % mod;
11058
+ data[o] = data[o - 1] + data[o]; // Uint8Array wraps values on assignment
11059
+ }
11060
+ }
11061
+ }
11062
+ const zipOverflow = new Error('Decompressed data exceeds expected size');
11063
+ // inflates data, stopping when output exceeds expected size (protects against zip bombs)
11064
+ function inflateLimited(compressed, expectedSize, reader) {
11065
+ const output = new Uint8Array(expectedSize);
11066
+ let position = 0;
11067
+ let overflow = false;
11068
+ const inflator = new pako_1.Inflate({ chunkSize: Math.max(1024, Math.min(expectedSize, 0x10000)) });
11069
+ inflator.onData = (chunk) => {
11070
+ const data = chunk;
11071
+ const count = Math.min(data.length, expectedSize - position);
11072
+ if (count > 0)
11073
+ output.set(count === data.length ? data : data.subarray(0, count), position);
11074
+ position += count;
11075
+ if (count < data.length) {
11076
+ overflow = true;
11077
+ throw zipOverflow;
10557
11078
  }
11079
+ };
11080
+ inflator.onEnd = (status) => {
11081
+ var _a;
11082
+ // default handler collects all the chunks into result, we only need the error status
11083
+ inflator.err = status;
11084
+ inflator.msg = ((_a = inflator.strm) === null || _a === void 0 ? void 0 : _a.msg) || '';
11085
+ };
11086
+ try {
11087
+ inflator.push(compressed, true);
10558
11088
  }
11089
+ catch (e) {
11090
+ if (e !== zipOverflow)
11091
+ throw e;
11092
+ }
11093
+ if (overflow) {
11094
+ if (reader)
11095
+ warnOrThrow(reader, zipOverflow.message);
11096
+ }
11097
+ else if (inflator.err) {
11098
+ throw new Error(`Invalid zip data: ${inflator.msg}`);
11099
+ }
11100
+ return output;
10559
11101
  }
10560
- function readDataZip(compressed, pixelData, width, height, bitDepth, step, offset, prediction) {
10561
- const decompressed = (0, pako_1.inflate)(compressed);
10562
- if (pixelData && offset < step) {
10563
- const array = bytesToArray(decompressed, bitDepth);
10564
- if (bitDepth === 8) {
10565
- if (prediction)
10566
- decodePredicted(decompressed, width, height, 0x100);
10567
- copyChannelToPixelData(pixelData, decompressed, offset, step);
10568
- }
10569
- else if (bitDepth === 16) {
10570
- if (prediction)
10571
- decodePredicted(array, width, height, 0x10000);
10572
- copyChannelToPixelData(pixelData, array, offset, step);
11102
+ function readDataZip(compressed, pixelData, width, height, bitDepth, step, offset, prediction, reader) {
11103
+ const bpv = bytesPerValue(bitDepth);
11104
+ if (!pixelData || offset < 0 || offset >= step)
11105
+ return;
11106
+ const data = pixelData.data;
11107
+ verifyArrayType(data, bpv);
11108
+ const expectedSize = width * height * bpv;
11109
+ if (reader)
11110
+ consumeMemory(reader, expectedSize);
11111
+ try {
11112
+ const decompressed = inflateLimited(compressed, expectedSize, reader);
11113
+ if (bpv === 1) {
11114
+ for (let y = 0, i = 0; y < height; y++) {
11115
+ let prev = 0;
11116
+ for (let x = 0, p = offset + y * width * step; x < width; x++, i++, p += step) {
11117
+ let v = decompressed[i];
11118
+ if (prediction)
11119
+ v = prev = (prev + v) & 0xff;
11120
+ data[p] = v;
11121
+ }
11122
+ }
10573
11123
  }
10574
- else if (bitDepth === 32) {
10575
- if (prediction)
10576
- decodePredicted(decompressed, width * 4, height, 0x100);
10577
- let di = offset;
10578
- const dst = new Uint32Array(pixelData.data.buffer, pixelData.data.byteOffset, pixelData.data.length);
10579
- for (let y = 0; y < height; y++) {
10580
- let a = width * 4 * y;
10581
- for (let x = 0; x < width; x++, a++, di += step) {
10582
- const b = a + width;
10583
- const c = b + width;
10584
- const d = c + width;
10585
- dst[di] = ((decompressed[a] << 24) | (decompressed[b] << 16) | (decompressed[c] << 8) | decompressed[d]) >>> 0;
11124
+ else if (bpv === 2) {
11125
+ for (let y = 0, i = 0; y < height; y++) {
11126
+ let prev = 0;
11127
+ for (let x = 0, p = offset + y * width * step; x < width; x++, i += 2, p += step) {
11128
+ let v = (decompressed[i] << 8) | decompressed[i + 1];
11129
+ if (prediction)
11130
+ v = prev = (prev + v) & 0xffff;
11131
+ data[p] = v;
10586
11132
  }
10587
11133
  }
10588
11134
  }
10589
11135
  else {
10590
- throw new Error('Invalid bitDepth');
11136
+ const dst = new Uint32Array(data.buffer, data.byteOffset, data.length);
11137
+ if (prediction) {
11138
+ // bytes are delta encoded per row and stored in planar order (all 1st bytes, all 2nd bytes, ...)
11139
+ decodePredicted(decompressed, width * 4, height);
11140
+ for (let y = 0, di = offset; y < height; y++) {
11141
+ let a = width * 4 * y;
11142
+ for (let x = 0; x < width; x++, a++, di += step) {
11143
+ const b = a + width;
11144
+ const c = b + width;
11145
+ const d = c + width;
11146
+ dst[di] = ((decompressed[a] << 24) | (decompressed[b] << 16) | (decompressed[c] << 8) | decompressed[d]) >>> 0;
11147
+ }
11148
+ }
11149
+ }
11150
+ else {
11151
+ const view = new DataView(decompressed.buffer, decompressed.byteOffset, decompressed.byteLength);
11152
+ for (let i = 0, j = 0, di = offset, size = width * height; i < size; i++, j += 4, di += step) {
11153
+ dst[di] = view.getUint32(j, false);
11154
+ }
11155
+ }
10591
11156
  }
10592
11157
  }
11158
+ finally {
11159
+ if (reader)
11160
+ recoverMemory(reader, expectedSize);
11161
+ }
10593
11162
  }
10594
- function readDataRLE(reader, pixelData, width, height, _bitDepth, step, offsets, large) {
10595
- const data = pixelData && pixelData.data;
10596
- let lengths;
10597
- if (large) {
10598
- consumeMemory(reader, offsets.length * height * 4);
10599
- lengths = new Uint32Array(offsets.length * height);
10600
- for (let o = 0, li = 0; o < offsets.length; o++) {
10601
- for (let y = 0; y < height; y++, li++) {
10602
- lengths[li] = readUint32(reader);
11163
+ // decodes single PackBits row, returns number of decoded values
11164
+ function decodeRLERow(src, i, end, dst, p, step, count) {
11165
+ let x = 0;
11166
+ while (i < end && x < count) {
11167
+ const header = src[i++];
11168
+ if (header > 128) {
11169
+ if (i >= end)
11170
+ break;
11171
+ const value = src[i++];
11172
+ let n = 257 - header;
11173
+ if (n > count - x)
11174
+ n = count - x;
11175
+ x += n;
11176
+ for (; n > 0; n--, p += step) {
11177
+ dst[p] = value;
11178
+ }
11179
+ }
11180
+ else if (header < 128) {
11181
+ let n = header + 1;
11182
+ if (n > count - x)
11183
+ n = count - x;
11184
+ if (n > end - i)
11185
+ n = end - i;
11186
+ x += n;
11187
+ for (; n > 0; n--, p += step) {
11188
+ dst[p] = src[i++];
10603
11189
  }
10604
11190
  }
11191
+ else {
11192
+ // ignore 128
11193
+ }
11194
+ }
11195
+ return x;
11196
+ }
11197
+ // converts big-endian 16/32-bit values from bytes and writes them to `data` starting at `p` with `step`
11198
+ function scatterValues(bytes, count, bpv, data, p, step) {
11199
+ if (bpv === 2) {
11200
+ for (let x = 0, i = 0; x < count; x++, i += 2, p += step) {
11201
+ data[p] = (bytes[i] << 8) | bytes[i + 1];
11202
+ }
10605
11203
  }
10606
11204
  else {
10607
- consumeMemory(reader, offsets.length * height * 2);
10608
- lengths = new Uint16Array(offsets.length * height);
10609
- for (let o = 0, li = 0; o < offsets.length; o++) {
10610
- for (let y = 0; y < height; y++, li++) {
10611
- lengths[li] = readUint16(reader);
10612
- }
11205
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
11206
+ for (let x = 0, i = 0; x < count; x++, i += 4, p += step) {
11207
+ data[p] = view.getFloat32(i, false);
10613
11208
  }
10614
11209
  }
10615
- // if (bitDepth !== 1 && bitDepth !== 8) throw new Error(`Invalid bit depth (${bitDepth})`);
10616
- const extraLimit = (step - 1) | 0; // 3 for rgb, 4 for cmyk
10617
- for (let c = 0, li = 0; c < offsets.length; c++) {
10618
- const offset = offsets[c] | 0;
10619
- const extra = c > extraLimit || offset > extraLimit;
10620
- if (!data || extra) {
10621
- for (let y = 0; y < height; y++, li++) {
10622
- skipBytes(reader, lengths[li]);
10623
- }
11210
+ }
11211
+ // decodes RLE rows of single channel, each row starts at the beginning of the image row
11212
+ function decodeRLEChannel(src, lengths, li, pos, width, height, data, offset, step, bpv, row) {
11213
+ const srcEnd = src.length;
11214
+ const rowSize = width * bpv;
11215
+ for (let y = 0; y < height; y++, li++) {
11216
+ const rowStart = pos < srcEnd ? pos : srcEnd;
11217
+ pos += lengths[li];
11218
+ const rowEnd = pos < srcEnd ? pos : srcEnd;
11219
+ if (rowStart >= rowEnd)
11220
+ continue;
11221
+ if (bpv === 1) {
11222
+ decodeRLERow(src, rowStart, rowEnd, data, offset + y * width * step, step, width);
10624
11223
  }
10625
11224
  else {
10626
- for (let y = 0, p = offset | 0; y < height; y++, li++) {
10627
- const length = lengths[li];
10628
- const buffer = readBytes(reader, length);
10629
- for (let i = 0, x = 0; i < length; i++) {
10630
- let header = buffer[i];
10631
- if (header > 128) {
10632
- const value = buffer[++i];
10633
- header = (256 - header) | 0;
10634
- for (let j = 0; j <= header && x < width; j = (j + 1) | 0, x = (x + 1) | 0) {
10635
- data[p] = value;
10636
- p = (p + step) | 0;
10637
- }
10638
- }
10639
- else if (header < 128) {
10640
- for (let j = 0; j <= header && x < width; j = (j + 1) | 0, x = (x + 1) | 0) {
10641
- data[p] = buffer[++i];
10642
- p = (p + step) | 0;
10643
- }
10644
- }
10645
- else {
10646
- // ignore 128
10647
- }
10648
- // This showed up on some images from non-photoshop programs, ignoring it seems to work just fine.
10649
- // if (i >= length) throw new Error(`Invalid RLE data: exceeded buffer size ${i}/${length}`);
10650
- }
11225
+ const decoded = decodeRLERow(src, rowStart, rowEnd, row, 0, 1, rowSize);
11226
+ scatterValues(row, Math.floor(decoded / bpv), bpv, data, offset + y * width * step, step);
11227
+ }
11228
+ }
11229
+ }
11230
+ function readDataRLE(reader, pixelData, width, height, bitDepth, step, offsets, large) {
11231
+ const data = pixelData && pixelData.data;
11232
+ const rows = offsets.length * height;
11233
+ const lengthSize = large ? 4 : 2;
11234
+ consumeMemory(reader, rows * lengthSize);
11235
+ try {
11236
+ if ((reader.offset + rows * lengthSize) > reader.view.byteLength) {
11237
+ throw new Error('RLE row lengths exceed buffer length');
11238
+ }
11239
+ const lengths = large ? new Uint32Array(rows) : new Uint16Array(rows);
11240
+ let total = 0;
11241
+ if (large) {
11242
+ for (let i = 0; i < rows; i++)
11243
+ total += (lengths[i] = readUint32(reader));
11244
+ }
11245
+ else {
11246
+ for (let i = 0; i < rows; i++)
11247
+ total += (lengths[i] = readUint16(reader));
11248
+ }
11249
+ const start = reader.offset;
11250
+ const srcEnd = reader.view.byteLength;
11251
+ if (total > (srcEnd - start)) {
11252
+ // broken or truncated file, decode only data that is available
11253
+ warnOrThrow(reader, 'RLE data exceeds buffer length');
11254
+ }
11255
+ const bpv = bytesPerValue(bitDepth);
11256
+ if (data)
11257
+ verifyArrayType(data, bpv);
11258
+ const src = new Uint8Array(reader.view.buffer, reader.view.byteOffset, srcEnd);
11259
+ const row = (data && bpv > 1) ? new Uint8Array(width * bpv) : undefined;
11260
+ let pos = start;
11261
+ for (let c = 0, li = 0; c < offsets.length; c++, li += height) {
11262
+ const offset = offsets[c] | 0;
11263
+ const channelStart = pos;
11264
+ for (let y = 0; y < height; y++)
11265
+ pos += lengths[li + y];
11266
+ if (data && offset >= 0 && offset < step) {
11267
+ decodeRLEChannel(src, lengths, li, channelStart, width, height, data, offset, step, bpv, row);
10651
11268
  }
10652
11269
  }
11270
+ reader.offset = pos;
11271
+ }
11272
+ finally {
11273
+ recoverMemory(reader, rows * lengthSize);
10653
11274
  }
10654
- recoverMemory(reader, lengths.byteLength);
10655
11275
  }
10656
11276
  function readSection(reader, round, func, skipEmpty = true, eightBytes = false) {
10657
11277
  let length = readUint32(reader);
@@ -10710,8 +11330,8 @@ function readColor(reader) {
10710
11330
  const l = readInt16(reader) / 10000;
10711
11331
  const ta = readInt16(reader);
10712
11332
  const tb = readInt16(reader);
10713
- const a = ta < 0 ? (ta / 12800) : (ta / 12700);
10714
- const b = tb < 0 ? (tb / 12800) : (tb / 12700);
11333
+ const a = (0, helpers_1.normalizeLabAB)(ta, 100);
11334
+ const b = (0, helpers_1.normalizeLabAB)(tb, 100);
10715
11335
  skipBytes(reader, 2);
10716
11336
  return { l, a, b };
10717
11337
  }
@@ -10911,6 +11531,8 @@ exports.writeUnicodeStringWithoutLength = writeUnicodeStringWithoutLength;
10911
11531
  exports.writeUnicodeStringWithoutLengthLE = writeUnicodeStringWithoutLengthLE;
10912
11532
  exports.writeUnicodeString = writeUnicodeString;
10913
11533
  exports.writeUnicodeStringWithPadding = writeUnicodeStringWithPadding;
11534
+ exports.getRLEChannelBound = getRLEChannelBound;
11535
+ exports.writeUint64 = writeUint64;
10914
11536
  exports.writeSection = writeSection;
10915
11537
  exports.writePsd = writePsd;
10916
11538
  exports.writeColor = writeColor;
@@ -11034,59 +11656,71 @@ function writeUnicodeStringWithPadding(writer, text) {
11034
11656
  }
11035
11657
  writeUint16(writer, 0);
11036
11658
  }
11037
- function getLargestLayerSize(layers = []) {
11659
+ // Worst-case size of writeDataRLE output for a single channel: per row the byte count (2 bytes, 4 for PSB)
11660
+ // plus PackBits data, which in the worst case is all literal runs of up to 128 bytes, each with 1 header byte.
11661
+ function getRLEChannelBound(width, height, large) {
11662
+ return height * ((large ? 4 : 2) + width + Math.ceil(width / 128));
11663
+ }
11664
+ function getLargestLayerSize(layers = [], large) {
11038
11665
  let max = 0;
11039
11666
  for (const layer of layers) {
11040
- const { width, height } = getLayerDimentions(layer);
11041
- max = Math.max(max, 2 * height + 2 * width * height);
11042
- if (layer.mask) {
11043
- const { width, height } = getLayerDimentions(layer.mask);
11044
- max = Math.max(max, 2 * height + 2 * width * height);
11045
- }
11046
- if (layer.realMask) {
11047
- const { width, height } = getLayerDimentions(layer.realMask);
11048
- max = Math.max(max, 2 * height + 2 * width * height);
11667
+ for (const target of [layer, layer.mask, layer.realMask]) {
11668
+ if (target) {
11669
+ const { width, height } = getLayerDimentions(target);
11670
+ max = Math.max(max, getRLEChannelBound(width, height, large));
11671
+ }
11049
11672
  }
11050
11673
  if (layer.children) {
11051
- max = Math.max(max, getLargestLayerSize(layer.children));
11674
+ max = Math.max(max, getLargestLayerSize(layer.children, large));
11052
11675
  }
11053
11676
  }
11054
11677
  return max;
11055
11678
  }
11679
+ function writeUint64(writer, value) {
11680
+ writeUint32(writer, Math.floor(value / 0x100000000));
11681
+ writeUint32(writer, value >>> 0);
11682
+ }
11056
11683
  function writeSection(writer, round, func, writeTotalLength = false, large = false) {
11684
+ const offset = writer.offset;
11057
11685
  if (large)
11058
11686
  writeUint32(writer, 0);
11059
- const offset = writer.offset;
11060
11687
  writeUint32(writer, 0);
11688
+ const start = writer.offset;
11061
11689
  func();
11062
- let length = writer.offset - offset - 4;
11690
+ let length = writer.offset - start;
11063
11691
  let len = length;
11064
11692
  while (len % round) {
11065
11693
  writeUint8(writer, 0);
11066
11694
  len++;
11067
11695
  }
11068
- // while (writer.offset % round) {
11069
- // writeUint8(writer, 0);
11070
- // len++;
11071
- // }
11072
11696
  if (writeTotalLength) {
11073
11697
  length = len;
11074
11698
  }
11075
- writer.view.setUint32(offset, length, false);
11699
+ if (large) {
11700
+ writer.view.setUint32(offset, Math.floor(length / 0x100000000), false);
11701
+ writer.view.setUint32(offset + 4, length >>> 0, false);
11702
+ }
11703
+ else {
11704
+ if (length > 0xffffffff)
11705
+ throw new Error('Section too large, use PSB format instead');
11706
+ writer.view.setUint32(offset, length, false);
11707
+ }
11708
+ }
11709
+ function verifyPixelData(data, name) {
11710
+ // check element size instead of instanceof, so arrays from other realms (iframes, workers, vm) are accepted
11711
+ const bytesPerElement = data && data.data.BYTES_PER_ELEMENT;
11712
+ if (bytesPerElement !== undefined && bytesPerElement !== 1) {
11713
+ throw new Error(`${name} has incorrect bitDepth (only 8-bit Uint8Array or Uint8ClampedArray data is supported for writing)`);
11714
+ }
11076
11715
  }
11077
11716
  function verifyBitCount(target) {
11078
- var _a;
11717
+ var _a, _b, _c;
11079
11718
  (_a = target.children) === null || _a === void 0 ? void 0 : _a.forEach(verifyBitCount);
11080
- const data = target.imageData;
11081
- if (data && (data.data instanceof Uint32Array || data.data instanceof Uint16Array)) {
11082
- throw new Error('imageData has incorrect bitDepth');
11083
- }
11084
- if ('mask' in target && target.mask) {
11085
- const data = target.mask.imageData;
11086
- if (data && (data.data instanceof Uint32Array || data.data instanceof Uint16Array)) {
11087
- throw new Error('mask imageData has incorrect bitDepth');
11088
- }
11089
- }
11719
+ verifyPixelData(target.imageData, 'imageData');
11720
+ if ('mask' in target)
11721
+ verifyPixelData((_b = target.mask) === null || _b === void 0 ? void 0 : _b.imageData, 'mask imageData');
11722
+ if ('realMask' in target)
11723
+ verifyPixelData((_c = target.realMask) === null || _c === void 0 ? void 0 : _c.imageData, 'realMask imageData');
11090
11724
  }
11091
11725
  function writePsd(writer, psd, options = {}) {
11092
11726
  var _a;
@@ -11097,6 +11731,10 @@ function writePsd(writer, psd, options = {}) {
11097
11731
  const bitsPerChannel = (_a = psd.bitsPerChannel) !== null && _a !== void 0 ? _a : 8;
11098
11732
  if (bitsPerChannel !== 8)
11099
11733
  throw new Error('bitsPerChannel other than 8 are not supported for writing');
11734
+ const layers = [];
11735
+ addChildren(layers, psd.children);
11736
+ if (!layers.length)
11737
+ layers.push({});
11100
11738
  verifyBitCount(psd);
11101
11739
  const imageResources = Object.assign({}, psd.imageResources);
11102
11740
  const opt = Object.assign(Object.assign({}, options), { layerIds: new Set(), layerToId: new Map() });
@@ -11110,8 +11748,8 @@ function writePsd(writer, psd, options = {}) {
11110
11748
  if (imageData && (psd.width !== imageData.width || psd.height !== imageData.height))
11111
11749
  throw new Error('Document canvas must have the same size as document');
11112
11750
  const globalAlpha = !!imageData && (0, helpers_1.hasAlpha)(imageData);
11113
- const maxBufferSize = Math.max(getLargestLayerSize(psd.children), 4 * 2 * psd.width * psd.height + 2 * psd.height);
11114
- writer.tempBuffer = new Uint8Array(maxBufferSize);
11751
+ // only used for encoding a single layer channel at a time, composite image is encoded directly into the writer buffer
11752
+ writer.tempBuffer = new Uint8Array(getLargestLayerSize(psd.children, !!options.psb));
11115
11753
  // header
11116
11754
  writeSignature(writer, '8BPS');
11117
11755
  writeUint16(writer, options.psb ? 2 : 1); // version
@@ -11134,10 +11772,6 @@ function writePsd(writer, psd, options = {}) {
11134
11772
  }
11135
11773
  // TODO: other data?
11136
11774
  });
11137
- const layers = [];
11138
- addChildren(layers, psd.children);
11139
- if (!layers.length)
11140
- layers.push({});
11141
11775
  // image resources
11142
11776
  imageResources.layersGroup = layers.map(l => l.linkGroup || 0);
11143
11777
  imageResources.layerGroupsEnabledId = layers.map(l => l.linkGroupEnabled == false ? 0 : 1);
@@ -11159,36 +11793,45 @@ function writePsd(writer, psd, options = {}) {
11159
11793
  writeGlobalLayerMaskInfo(writer, psd.globalLayerMaskInfo);
11160
11794
  writeAdditionalLayerInfo(writer, psd, psd, opt);
11161
11795
  }, undefined, !!opt.psb);
11796
+ writer.tempBuffer = undefined;
11162
11797
  // image data
11163
- const channels = globalAlpha ? [0, 1, 2, 3] : [0, 1, 2];
11164
- const width = imageData ? imageData.width : psd.width;
11165
- const height = imageData ? imageData.height : psd.height;
11166
- const data = { data: new Uint8Array(width * height * 4), width, height };
11167
11798
  writeUint16(writer, 1 /* Compression.RleCompressed */); // Photoshop doesn't support zip compression of composite image data
11168
11799
  if (helpers_1.RAW_IMAGE_DATA && psd.imageDataRaw) {
11169
11800
  console.log('writing raw image data');
11170
11801
  writeBytes(writer, psd.imageDataRaw);
11171
11802
  }
11172
11803
  else {
11173
- if (imageData)
11174
- data.data.set(new Uint8Array(imageData.data.buffer, imageData.data.byteOffset, imageData.data.byteLength));
11175
- // add weird white matte
11176
- if (globalAlpha) {
11177
- const size = data.width * data.height * 4;
11178
- const p = data.data;
11179
- for (let i = 0; i < size; i += 4) {
11180
- const pa = p[i + 3];
11181
- if (pa != 0 && pa != 255) {
11182
- const a = pa / 255;
11183
- const ra = 255 * (1 - a);
11184
- p[i + 0] = p[i + 0] * a + ra;
11185
- p[i + 1] = p[i + 1] * a + ra;
11186
- p[i + 2] = p[i + 2] * a + ra;
11187
- }
11804
+ const channels = globalAlpha ? [0, 1, 2, 3] : [0, 1, 2];
11805
+ const data = getCompositeData(imageData, psd.width, psd.height, globalAlpha);
11806
+ // encode directly into the writer buffer
11807
+ const maxSize = channels.length * getRLEChannelBound(data.width, data.height, !!options.psb);
11808
+ ensureSize(writer, writer.offset + maxSize);
11809
+ const buffer = new Uint8Array(writer.buffer, writer.offset, maxSize);
11810
+ writer.offset += (0, helpers_1.writeDataRLE)(buffer, data, channels, !!options.psb).length;
11811
+ }
11812
+ }
11813
+ function getCompositeData(imageData, width, height, globalAlpha) {
11814
+ if (!imageData)
11815
+ return { data: new Uint8Array(width * height * 4), width, height };
11816
+ const size = width * height * 4;
11817
+ const src = imageData.data;
11818
+ let dst = undefined;
11819
+ // add weird white matte (copy the data only if there are semi-transparent pixels)
11820
+ if (globalAlpha) {
11821
+ for (let i = 0; i < size; i += 4) {
11822
+ const pa = src[i + 3];
11823
+ if (pa != 0 && pa != 255) {
11824
+ if (!dst)
11825
+ dst = new Uint8Array(src.buffer, src.byteOffset, size).slice();
11826
+ const a = pa / 255;
11827
+ const ra = 255 * (1 - a);
11828
+ dst[i + 0] = src[i + 0] * a + ra;
11829
+ dst[i + 1] = src[i + 1] * a + ra;
11830
+ dst[i + 2] = src[i + 2] * a + ra;
11188
11831
  }
11189
11832
  }
11190
- writeBytes(writer, (0, helpers_1.writeDataRLE)(writer.tempBuffer, data, channels, !!options.psb));
11191
11833
  }
11834
+ return dst ? { data: dst, width, height } : imageData;
11192
11835
  }
11193
11836
  function writeLayerInfo(writer, layers, psd, globalAlpha, options) {
11194
11837
  writeSection(writer, 4, () => {
@@ -11205,9 +11848,12 @@ function writeLayerInfo(writer, layers, psd, globalAlpha, options) {
11205
11848
  writeUint16(writer, channels.length);
11206
11849
  for (const c of channels) {
11207
11850
  writeInt16(writer, c.id);
11208
- if (options.psb)
11209
- writeUint32(writer, 0);
11210
- writeUint32(writer, c.length);
11851
+ if (options.psb) {
11852
+ writeUint64(writer, c.length);
11853
+ }
11854
+ else {
11855
+ writeUint32(writer, c.length);
11856
+ }
11211
11857
  }
11212
11858
  writeSignature(writer, '8BIM');
11213
11859
  writeSignature(writer, helpers_1.fromBlendMode[layer.blendMode] || 'norm');
@@ -11244,7 +11890,7 @@ function writeLayerInfo(writer, layers, psd, globalAlpha, options) {
11244
11890
  }, true, options.psb);
11245
11891
  }
11246
11892
  function writeLayerMaskData(writer, { mask, realMask }, layerData) {
11247
- writeSection(writer, 1, () => {
11893
+ writeSection(writer, 4, () => {
11248
11894
  if (!mask && !realMask)
11249
11895
  return;
11250
11896
  let params = 0, flags = 0, realFlags = 0;
@@ -11299,8 +11945,7 @@ function writeLayerMaskData(writer, { mask, realMask }, layerData) {
11299
11945
  if (mask.vectorMaskFeather !== undefined)
11300
11946
  writeFloat64(writer, mask.vectorMaskFeather);
11301
11947
  }
11302
- writeZeros(writer, 2);
11303
- });
11948
+ }, true); // photoshop pads mask data to multiple of 4 bytes and includes padding in the length
11304
11949
  }
11305
11950
  function writerBlendingRange(writer, range) {
11306
11951
  writeUint8(writer, range[0]);
@@ -11329,7 +11974,7 @@ function writeGlobalLayerMaskInfo(writer, info) {
11329
11974
  writeUint16(writer, info.colorSpace2);
11330
11975
  writeUint16(writer, info.colorSpace3);
11331
11976
  writeUint16(writer, info.colorSpace4);
11332
- writeUint16(writer, Math.round(info.opacity * 0xff));
11977
+ writeUint16(writer, Math.round((0, helpers_1.clamp)(info.opacity, 0, 1) * 100)); // 0-100
11333
11978
  writeUint8(writer, info.kind);
11334
11979
  writeZeros(writer, 3);
11335
11980
  }
@@ -11345,7 +11990,7 @@ function writeAdditionalLayerInfo(writer, target, psd, options) {
11345
11990
  if (handler.has(target)) {
11346
11991
  const large = options.psb && helpers_1.largeAdditionalInfoKeys.indexOf(key) !== -1;
11347
11992
  const writeTotalLength = key !== 'Txt2' && key !== 'cinf' && key !== 'extn' && key !== 'CAI ' && key !== 'OCIO';
11348
- const fourBytes = key === 'Txt2' || key === 'luni' || key === 'vmsk' || key === 'artb' || key === 'artd' ||
11993
+ const fourBytes = key === 'levl' || key === 'Txt2' || key === 'luni' || key === 'vmsk' || key === 'artb' || key === 'artd' ||
11349
11994
  key === 'vogk' || key === 'SoLd' || key === 'lnk2' || key === 'vscg' || key === 'vsms' || key === 'GdFl' ||
11350
11995
  key === 'lmfx' || key === 'lrFX' || key === 'cinf' || key === 'PlLd' || key === 'Anno' || key === 'CAI ' || key === 'OCIO' || key === 'GenI' || key === 'FEid' || key === 'curv' || key === 'CgEd' || key === 'vibA' || key === 'blwh' || key === 'grdm';
11351
11996
  writeSignature(writer, large ? '8B64' : '8BIM');
@@ -11397,10 +12042,8 @@ function addChildren(layers, children) {
11397
12042
  }
11398
12043
  }
11399
12044
  function resizeBuffer(writer, size) {
11400
- let newLength = writer.buffer.byteLength;
11401
- do {
11402
- newLength *= 2;
11403
- } while (size > newLength);
12045
+ // grow at least 2x to keep small writes fast, but don't overshoot large reservations (like composite image data)
12046
+ const newLength = Math.max(writer.buffer.byteLength * 2, size);
11404
12047
  const newBuffer = new ArrayBuffer(newLength);
11405
12048
  const newBytes = new Uint8Array(newBuffer);
11406
12049
  const oldBytes = new Uint8Array(writer.buffer);
@@ -11423,12 +12066,12 @@ function createThumbnail(psd) {
11423
12066
  let scale = 1;
11424
12067
  if (psd.width > psd.height) {
11425
12068
  canvas.width = 160;
11426
- canvas.height = Math.floor(psd.height * (canvas.width / psd.width));
12069
+ canvas.height = Math.max(1, Math.floor(psd.height * (canvas.width / psd.width)));
11427
12070
  scale = canvas.width / psd.width;
11428
12071
  }
11429
12072
  else {
11430
12073
  canvas.height = 160;
11431
- canvas.width = Math.floor(psd.width * (canvas.height / psd.height));
12074
+ canvas.width = Math.max(1, Math.floor(psd.width * (canvas.height / psd.height)));
11432
12075
  scale = canvas.height / psd.height;
11433
12076
  }
11434
12077
  const context = canvas.getContext('2d');
@@ -11471,7 +12114,7 @@ function getMaskChannels(tempBuffer, layerData, layer, mask, options, realMask)
11471
12114
  compression = 2 /* Compression.ZipWithoutPrediction */;
11472
12115
  }
11473
12116
  else {
11474
- buffer = (0, helpers_1.writeDataRLE)(tempBuffer, imageData, [0], !!options.psb);
12117
+ buffer = (0, helpers_1.writeDataRLE)(tempBuffer, imageData, [0], !!options.psb).slice(); // copy, temp buffer is reused
11475
12118
  compression = 1 /* Compression.RleCompressed */;
11476
12119
  }
11477
12120
  layerData.channels.push({ id: realMask ? -3 /* ChannelID.RealUserMask */ : -2 /* ChannelID.UserMask */, compression, data: buffer, length: 2 + buffer.length });
@@ -11579,7 +12222,7 @@ function getLayerChannels(tempBuffer, layer, background, options) {
11579
12222
  compression = 2 /* Compression.ZipWithoutPrediction */;
11580
12223
  }
11581
12224
  else {
11582
- data = (0, helpers_1.writeDataRLE)(tempBuffer, imageData, [offset], !!options.psb);
12225
+ data = (0, helpers_1.writeDataRLE)(tempBuffer, imageData, [offset], !!options.psb).slice(); // copy, temp buffer is reused
11583
12226
  compression = 1 /* Compression.RleCompressed */;
11584
12227
  }
11585
12228
  return { id, compression, data, length: 2 + data.length };
@@ -11643,8 +12286,8 @@ function writeColor(writer, color) {
11643
12286
  else if ('l' in color) {
11644
12287
  writeUint16(writer, 7 /* ColorSpace.Lab */);
11645
12288
  writeInt16(writer, Math.round(color.l * 10000));
11646
- writeInt16(writer, Math.round(color.a < 0 ? (color.a * 12800) : (color.a * 12700)));
11647
- writeInt16(writer, Math.round(color.b < 0 ? (color.b * 12800) : (color.b * 12700)));
12289
+ writeInt16(writer, Math.round((0, helpers_1.denormalizeLabAB)(color.a, 100)));
12290
+ writeInt16(writer, Math.round((0, helpers_1.denormalizeLabAB)(color.b, 100)));
11648
12291
  writeUint16(writer, 0);
11649
12292
  }
11650
12293
  else if ('h' in color) {
@@ -11694,6 +12337,9 @@ function writePattern(writer, pattern) {
11694
12337
  writeUint32(writer, bottom);
11695
12338
  writeUint32(writer, right);
11696
12339
  writeUint32(writer, 24); // channels count
12340
+ // ponytail: pattern channels always use small (2-byte) RLE scanline headers, matching
12341
+ // readPattern which reads them as non-large
12342
+ const buffer = new Uint8Array(getRLEChannelBound(width, height, false));
11697
12343
  // channels: RGB at indices 0,1,2 and alpha at index 25
11698
12344
  for (let i = 0; i < 24 + 2; i++) {
11699
12345
  const offset = i < 3 ? i : (i === 25 ? 3 : -1);
@@ -11701,10 +12347,6 @@ function writePattern(writer, pattern) {
11701
12347
  writeUint32(writer, 0); // has
11702
12348
  continue;
11703
12349
  }
11704
- // worst-case RLE size for a single channel: width + 1 per scanline, plus scanline length headers
11705
- const buffer = new Uint8Array(width * height + 2 * height + 2 * width + 16);
11706
- // ponytail: pattern channels always use small (2-byte) RLE scanline headers, matching
11707
- // readPattern which reads them as non-large; `large` here only affects the header width.
11708
12350
  const data = (0, helpers_1.writeDataRLE)(buffer, pixelData, [offset], false);
11709
12351
  writeUint32(writer, 1); // has
11710
12352
  writeUint32(writer, data.length + 4 + 16 + 2 + 1); // length
@@ -11732,6 +12374,7 @@ function writePattern(writer, pattern) {
11732
12374
  Object.defineProperty(exports, "__esModule", { value: true });
11733
12375
  exports.decodeEngineData = decodeEngineData;
11734
12376
  exports.encodeEngineData = encodeEngineData;
12377
+ const helpers_1 = require("./helpers");
11735
12378
  const defaultFont = {
11736
12379
  name: 'MyriadPro-Regular',
11737
12380
  script: 0,
@@ -11844,6 +12487,26 @@ function decodeColor(color) {
11844
12487
  default: throw new Error('Unknown color type in text layer');
11845
12488
  }
11846
12489
  }
12490
+ // h, s, b in 0..1 range, returns r, g, b in 0..1 range
12491
+ function hsbToRgb(h, s, v) {
12492
+ h = (0, helpers_1.clamp)(h || 0, 0, 1);
12493
+ s = (0, helpers_1.clamp)(s || 0, 0, 1);
12494
+ v = (0, helpers_1.clamp)(v || 0, 0, 1);
12495
+ const h6 = (h * 6) % 6;
12496
+ const i = Math.floor(h6);
12497
+ const f = h6 - i;
12498
+ const p = v * (1 - s);
12499
+ const q = v * (1 - s * f);
12500
+ const t = v * (1 - s * (1 - f));
12501
+ switch (i) {
12502
+ case 0: return [v, t, p];
12503
+ case 1: return [q, v, p];
12504
+ case 2: return [p, v, t];
12505
+ case 3: return [p, q, v];
12506
+ case 4: return [t, p, v];
12507
+ default: return [v, p, q];
12508
+ }
12509
+ }
11847
12510
  function encodeColor(color) {
11848
12511
  if (!color) {
11849
12512
  return { Type: 1, Values: [0, 0, 0, 0] };
@@ -11851,9 +12514,19 @@ function encodeColor(color) {
11851
12514
  else if ('r' in color) {
11852
12515
  return { Type: 1, Values: ['a' in color ? color.a / 255 : 1, color.r / 255, color.g / 255, color.b / 255] };
11853
12516
  }
12517
+ else if ('fr' in color) {
12518
+ return { Type: 1, Values: [1, (0, helpers_1.clamp)(color.fr || 0, 0, 1), (0, helpers_1.clamp)(color.fg || 0, 0, 1), (0, helpers_1.clamp)(color.fb || 0, 0, 1)] };
12519
+ }
12520
+ else if ('h' in color) {
12521
+ const [r, g, b] = hsbToRgb(color.h, color.s, color.b);
12522
+ return { Type: 1, Values: [1, r, g, b] };
12523
+ }
11854
12524
  else if ('c' in color) {
11855
12525
  return { Type: 2, Values: [1, color.c / 255, color.m / 255, color.y / 255, color.k / 255] };
11856
12526
  }
12527
+ else if ('l' in color) {
12528
+ throw new Error('LAB colors are not supported in text layers, use RGB, CMYK or grayscale color instead');
12529
+ }
11857
12530
  else if ('k' in color) {
11858
12531
  return { Type: 0, Values: [1, color.k / 255] };
11859
12532
  }
@@ -11891,16 +12564,19 @@ function findOrAddFont(fonts, font) {
11891
12564
  return fonts.length - 1;
11892
12565
  }
11893
12566
  function decodeObject(obj, keys, fonts) {
12567
+ var _a;
11894
12568
  const result = {};
11895
12569
  for (const key of keys) {
11896
12570
  const Key = upperFirst(key);
11897
12571
  if (obj[Key] === undefined)
11898
12572
  continue;
11899
12573
  if (key === 'justification') {
11900
- result[key] = justification[obj[Key]];
12574
+ result[key] = (_a = justification[obj[Key]]) !== null && _a !== void 0 ? _a : 'left';
11901
12575
  }
11902
12576
  else if (key === 'font') {
11903
- result[key] = fonts[obj[Key]];
12577
+ const font = fonts[obj[Key]];
12578
+ if (font)
12579
+ result[key] = font; // invalid font index, leave the font unset so it falls back to default
11904
12580
  }
11905
12581
  else if (key === 'fillColor' || key === 'strokeColor') {
11906
12582
  result[key] = decodeColor(obj[Key]);
@@ -11919,7 +12595,7 @@ function encodeObject(obj, keys, fonts) {
11919
12595
  if (obj[key] === undefined)
11920
12596
  continue;
11921
12597
  if (key === 'justification') {
11922
- result[Key] = justification.indexOf((_a = obj[key]) !== null && _a !== void 0 ? _a : 'left');
12598
+ result[Key] = Math.max(0, justification.indexOf((_a = obj[key]) !== null && _a !== void 0 ? _a : 'left')); // default to 'left' for unknown values
11923
12599
  }
11924
12600
  else if (key === 'font') {
11925
12601
  result[Key] = findOrAddFont(fonts, obj[key]);
@@ -11987,8 +12663,38 @@ function deduplicateValues(base, runs, keys) {
11987
12663
  runs.length = 0;
11988
12664
  }
11989
12665
  }
12666
+ function isDefaultGridColor(color) {
12667
+ // Photoshop writes default grid colors as blue with 0 alpha, ignore alpha when comparing
12668
+ return !!color && 'r' in color && color.r === 0 && color.g === 0 && color.b === 255;
12669
+ }
12670
+ function decodeGridColor(color, defaultColor) {
12671
+ try {
12672
+ return color ? decodeColor(color) : defaultColor;
12673
+ }
12674
+ catch (_a) {
12675
+ return defaultColor; // don't fail whole text layer because of invalid grid color
12676
+ }
12677
+ }
12678
+ function decodeGridInfo(grid) {
12679
+ var _a, _b;
12680
+ if (!grid || typeof grid !== 'object')
12681
+ return undefined;
12682
+ const result = {
12683
+ isOn: !!grid.GridIsOn,
12684
+ show: !!grid.ShowGrid,
12685
+ size: (_a = grid.GridSize) !== null && _a !== void 0 ? _a : defaultGridInfo.size,
12686
+ leading: (_b = grid.GridLeading) !== null && _b !== void 0 ? _b : defaultGridInfo.leading,
12687
+ color: decodeGridColor(grid.GridColor, defaultGridInfo.color),
12688
+ leadingFillColor: decodeGridColor(grid.GridLeadingFillColor, defaultGridInfo.leadingFillColor),
12689
+ alignLineHeightToGridFlags: !!grid.AlignLineHeightToGridFlags,
12690
+ };
12691
+ const isDefault = !result.isOn && !result.show && result.size === defaultGridInfo.size &&
12692
+ result.leading === defaultGridInfo.leading && !result.alignLineHeightToGridFlags &&
12693
+ isDefaultGridColor(result.color) && isDefaultGridColor(result.leadingFillColor);
12694
+ return isDefault ? undefined : result;
12695
+ }
11990
12696
  function decodeEngineData(engineData) {
11991
- var _a, _b, _c, _d, _e, _f;
12697
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
11992
12698
  // console.log('engineData', require('util').inspect(engineData, false, 99, true));
11993
12699
  const engineDict = engineData.EngineDict;
11994
12700
  const resourceDict = engineData.ResourceDict;
@@ -12000,9 +12706,11 @@ function decodeEngineData(engineData) {
12000
12706
  }));
12001
12707
  let text = engineDict.Editor.Text.replace(/\r/g, '\n');
12002
12708
  let removedCharacters = 0;
12003
- while (/\n$/.test(text)) {
12709
+ // Photoshop always appends exactly one trailing \r (and encoder adds one back), any additional
12710
+ // trailing new lines are empty paragraphs that are part of the text
12711
+ if (/\n$/.test(text)) {
12004
12712
  text = text.substring(0, text.length - 1);
12005
- removedCharacters++;
12713
+ removedCharacters = 1;
12006
12714
  }
12007
12715
  const result = {
12008
12716
  text,
@@ -12023,6 +12731,10 @@ function decodeEngineData(engineData) {
12023
12731
  if (photoshop.BoxBounds)
12024
12732
  result.boxBounds = photoshop.BoxBounds;
12025
12733
  }
12734
+ // grid info (only included when it differs from defaults, to avoid noise in common case)
12735
+ const gridInfo = decodeGridInfo(engineDict.GridInfo);
12736
+ if (gridInfo)
12737
+ result.gridInfo = gridInfo;
12026
12738
  // paragraph style
12027
12739
  // const theNormalParagraphSheet = resourceDict.TheNormalParagraphSheet;
12028
12740
  // const paragraphSheetSet = resourceDict.ParagraphSheetSet;
@@ -12053,13 +12765,17 @@ function decodeEngineData(engineData) {
12053
12765
  // const styleSheetSet = resourceDict.StyleSheetSet;
12054
12766
  // const styleSheetData = styleSheetSet[theNormalStyleSheet].StyleSheetData;
12055
12767
  const styleRun = engineDict.StyleRun;
12768
+ // style runs without a font use the font of the normal style sheet
12769
+ const normalStyleSheet = (_j = (_g = resourceDict.StyleSheetSet) === null || _g === void 0 ? void 0 : _g[(_h = resourceDict.TheNormalStyleSheet) !== null && _h !== void 0 ? _h : 0]) === null || _j === void 0 ? void 0 : _j.StyleSheetData;
12770
+ const normalFontIndex = normalStyleSheet === null || normalStyleSheet === void 0 ? void 0 : normalStyleSheet.Font;
12771
+ const normalFont = (_k = (normalFontIndex !== undefined ? fonts[normalFontIndex] : undefined)) !== null && _k !== void 0 ? _k : fonts[0];
12056
12772
  result.style = {}; // decodeStyle(styleSheetData, fonts);
12057
12773
  result.styleRuns = [];
12058
12774
  for (let i = 0; i < styleRun.RunArray.length; i++) {
12059
12775
  const length = styleRun.RunLengthArray[i];
12060
12776
  const style = decodeStyle(styleRun.RunArray[i].StyleSheet.StyleSheetData, fonts);
12061
- if (!style.font)
12062
- style.font = fonts[0];
12777
+ if (!style.font && normalFont)
12778
+ style.font = normalFont;
12063
12779
  result.styleRuns.push({ length, style });
12064
12780
  }
12065
12781
  for (let counter = removedCharacters; result.styleRuns.length && counter > 0; counter--) {
@@ -12072,16 +12788,42 @@ function decodeEngineData(engineData) {
12072
12788
  delete result.styleRuns;
12073
12789
  return result;
12074
12790
  }
12791
+ // Adjusts run lengths (specified in terms of the original text) for characters removed from the text
12792
+ // (\r characters of \r\n pairs that are collapsed into single \r)
12793
+ function adjustRunLengths(runs, removed) {
12794
+ if (!runs || !removed.length)
12795
+ return runs;
12796
+ let start = 0;
12797
+ let removedIndex = 0;
12798
+ return runs.map(run => {
12799
+ const length = Math.max(0, run.length || 0);
12800
+ const end = start + length;
12801
+ let count = 0;
12802
+ while (removedIndex < removed.length && removed[removedIndex] < end) {
12803
+ if (removed[removedIndex] >= start)
12804
+ count++;
12805
+ removedIndex++;
12806
+ }
12807
+ start = end;
12808
+ return Object.assign(Object.assign({}, run), { length: length - count });
12809
+ });
12810
+ }
12075
12811
  function encodeEngineData(data) {
12076
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
12077
- const text = `${(data.text || '').replace(/\r?\n/g, '\r')}\r`;
12812
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
12813
+ const sourceText = data.text || '';
12814
+ const removedIndices = []; // indices of \r characters removed from \r\n pairs
12815
+ for (let i = 0; i < sourceText.length - 1; i++) {
12816
+ if (sourceText.charCodeAt(i) === 13 && sourceText.charCodeAt(i + 1) === 10)
12817
+ removedIndices.push(i);
12818
+ }
12819
+ const text = `${sourceText.replace(/\r?\n/g, '\r')}\r`;
12078
12820
  const fonts = [
12079
12821
  { name: 'AdobeInvisFont', script: 0, type: 0, synthetic: 0 },
12080
12822
  ];
12081
12823
  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;
12082
12824
  const paragraphRunArray = [];
12083
12825
  const paragraphRunLengthArray = [];
12084
- const paragraphRuns = data.paragraphStyleRuns;
12826
+ const paragraphRuns = adjustRunLengths(data.paragraphStyleRuns, removedIndices);
12085
12827
  if (paragraphRuns && paragraphRuns.length) {
12086
12828
  let leftLength = text.length;
12087
12829
  for (const run of paragraphRuns) {
@@ -12130,7 +12872,9 @@ function encodeEngineData(data) {
12130
12872
  }
12131
12873
  }
12132
12874
  const styleSheetData = encodeStyle(Object.assign(Object.assign({}, defaultStyle), { font: defFont }), fonts);
12133
- const styleRuns = data.styleRuns || [{ length: text.length, style: data.style || {} }];
12875
+ const styleRuns = ((_d = data.styleRuns) === null || _d === void 0 ? void 0 : _d.length) ?
12876
+ adjustRunLengths(data.styleRuns, removedIndices) :
12877
+ [{ length: text.length, style: data.style || {} }];
12134
12878
  const styleRunArray = [];
12135
12879
  const styleRunLengthArray = [];
12136
12880
  let leftLength = text.length;
@@ -12152,7 +12896,7 @@ function encodeEngineData(data) {
12152
12896
  });
12153
12897
  }
12154
12898
  // add extra run to the end if existing ones didn't fill it up
12155
- if (leftLength && styleRuns.length) {
12899
+ if (leftLength) {
12156
12900
  styleRunLengthArray.push(leftLength);
12157
12901
  styleRunArray.push({
12158
12902
  StyleSheet: {
@@ -12161,6 +12905,7 @@ function encodeEngineData(data) {
12161
12905
  });
12162
12906
  }
12163
12907
  const gridInfo = Object.assign(Object.assign({}, defaultGridInfo), data.gridInfo);
12908
+ const antiAliasIndex = antialias.indexOf((_e = data.antiAlias) !== null && _e !== void 0 ? _e : 'sharp');
12164
12909
  const WritingDirection = data.orientation === 'vertical' ? 2 : 0;
12165
12910
  const Procession = data.orientation === 'vertical' ? 1 : 0;
12166
12911
  const ShapeType = data.shapeType === 'box' ? 1 : 0;
@@ -12224,11 +12969,11 @@ function encodeEngineData(data) {
12224
12969
  FontType: f.type || 0,
12225
12970
  Synthetic: f.synthetic || 0,
12226
12971
  })),
12227
- SuperscriptSize: (_d = data.superscriptSize) !== null && _d !== void 0 ? _d : 0.583,
12228
- SuperscriptPosition: (_e = data.superscriptPosition) !== null && _e !== void 0 ? _e : 0.333,
12229
- SubscriptSize: (_f = data.subscriptSize) !== null && _f !== void 0 ? _f : 0.583,
12230
- SubscriptPosition: (_g = data.subscriptPosition) !== null && _g !== void 0 ? _g : 0.333,
12231
- SmallCapSize: (_h = data.smallCapSize) !== null && _h !== void 0 ? _h : 0.7,
12972
+ SuperscriptSize: (_f = data.superscriptSize) !== null && _f !== void 0 ? _f : 0.583,
12973
+ SuperscriptPosition: (_g = data.superscriptPosition) !== null && _g !== void 0 ? _g : 0.333,
12974
+ SubscriptSize: (_h = data.subscriptSize) !== null && _h !== void 0 ? _h : 0.583,
12975
+ SubscriptPosition: (_j = data.subscriptPosition) !== null && _j !== void 0 ? _j : 0.333,
12976
+ SmallCapSize: (_k = data.smallCapSize) !== null && _k !== void 0 ? _k : 0.7,
12232
12977
  };
12233
12978
  const engineData = {
12234
12979
  EngineDict: {
@@ -12251,14 +12996,14 @@ function encodeEngineData(data) {
12251
12996
  GridInfo: {
12252
12997
  GridIsOn: !!gridInfo.isOn,
12253
12998
  ShowGrid: !!gridInfo.show,
12254
- GridSize: (_j = gridInfo.size) !== null && _j !== void 0 ? _j : 18,
12255
- GridLeading: (_k = gridInfo.leading) !== null && _k !== void 0 ? _k : 22,
12999
+ GridSize: (_l = gridInfo.size) !== null && _l !== void 0 ? _l : 18,
13000
+ GridLeading: (_m = gridInfo.leading) !== null && _m !== void 0 ? _m : 22,
12256
13001
  GridColor: encodeColor(gridInfo.color),
12257
- GridLeadingFillColor: encodeColor(gridInfo.color),
13002
+ GridLeadingFillColor: encodeColor(gridInfo.leadingFillColor),
12258
13003
  AlignLineHeightToGridFlags: !!gridInfo.alignLineHeightToGridFlags,
12259
13004
  },
12260
- AntiAlias: antialias.indexOf((_l = data.antiAlias) !== null && _l !== void 0 ? _l : 'sharp'),
12261
- UseFractionalGlyphWidths: (_m = data.useFractionalGlyphWidths) !== null && _m !== void 0 ? _m : true,
13005
+ AntiAlias: antiAliasIndex === -1 ? antialias.indexOf('sharp') : antiAliasIndex,
13006
+ UseFractionalGlyphWidths: (_o = data.useFractionalGlyphWidths) !== null && _o !== void 0 ? _o : true,
12262
13007
  Rendered: {
12263
13008
  Version: 1,
12264
13009
  Shapes: {
@@ -12281,7 +13026,7 @@ function encodeEngineData(data) {
12281
13026
  return engineData;
12282
13027
  }
12283
13028
 
12284
- },{}],16:[function(require,module,exports){
13029
+ },{"./helpers":8}],16:[function(require,module,exports){
12285
13030
  "use strict";
12286
13031
  Object.defineProperty(exports, "__esModule", { value: true });
12287
13032
  exports.stringLengthInBytes = stringLengthInBytes;
@@ -12302,30 +13047,44 @@ function charLengthInBytes(code) {
12302
13047
  return 4;
12303
13048
  }
12304
13049
  }
12305
- // Reads a scalar value at index `i`, replacing unpaired surrogates with U+FFFD,
13050
+ // Returns scalar value at index `i` (combining surrogate pairs), replacing unpaired surrogates with U+FFFD,
12306
13051
  // matching how TextEncoder converts a string to a sequence of Unicode scalar values.
13052
+ // Values above 0xffff always take 2 UTF-16 code units.
12307
13053
  function codePointAt(value, i) {
12308
13054
  const code = value.charCodeAt(i);
13055
+ if (code < 0xd800 || code > 0xdfff)
13056
+ return code;
12309
13057
  // high surrogate
12310
- if (code >= 0xd800 && code <= 0xdbff && (i + 1) < value.length) {
13058
+ if (code <= 0xdbff && (i + 1) < value.length) {
12311
13059
  const extra = value.charCodeAt(i + 1);
12312
13060
  // low surrogate
12313
13061
  if (extra >= 0xdc00 && extra <= 0xdfff) {
12314
- return { code: ((code & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000, size: 2 };
13062
+ return ((code & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
12315
13063
  }
12316
13064
  }
12317
13065
  // unpaired surrogate (lone high or lone low)
12318
- if (code >= 0xd800 && code <= 0xdfff) {
12319
- return { code: 0xfffd, size: 1 };
12320
- }
12321
- return { code, size: 1 };
13066
+ return 0xfffd;
12322
13067
  }
12323
13068
  function stringLengthInBytes(value) {
12324
13069
  let result = 0;
12325
- for (let i = 0; i < value.length;) {
12326
- const { code, size } = codePointAt(value, i);
12327
- result += charLengthInBytes(code);
12328
- i += size;
13070
+ for (let i = 0; i < value.length; i++) {
13071
+ const code = value.charCodeAt(i);
13072
+ if (code < 0x80) {
13073
+ result += 1;
13074
+ }
13075
+ else if (code < 0x800) {
13076
+ result += 2;
13077
+ }
13078
+ else {
13079
+ const scalar = codePointAt(value, i);
13080
+ if (scalar > 0xffff) {
13081
+ result += 4;
13082
+ i++;
13083
+ }
13084
+ else {
13085
+ result += 3;
13086
+ }
13087
+ }
12329
13088
  }
12330
13089
  return result;
12331
13090
  }
@@ -12354,10 +13113,17 @@ function writeCharacter(buffer, offset, code) {
12354
13113
  return length;
12355
13114
  }
12356
13115
  function encodeStringTo(buffer, offset, value) {
12357
- for (let i = 0; i < value.length;) {
12358
- const { code, size } = codePointAt(value, i);
12359
- offset += writeCharacter(buffer, offset, code);
12360
- i += size;
13116
+ for (let i = 0; i < value.length; i++) {
13117
+ const code = value.charCodeAt(i);
13118
+ if (code < 0x80) {
13119
+ buffer[offset++] = code;
13120
+ }
13121
+ else {
13122
+ const scalar = codePointAt(value, i);
13123
+ if (scalar > 0xffff)
13124
+ i++;
13125
+ offset += writeCharacter(buffer, offset, scalar);
13126
+ }
12361
13127
  }
12362
13128
  return offset;
12363
13129
  }