@payloadcms/transformer-sharp 4.0.0-internal.58473b9

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 (75) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +105 -0
  3. package/dist/canResizeImage.d.ts +2 -0
  4. package/dist/canResizeImage.d.ts.map +1 -0
  5. package/dist/canResizeImage.js +12 -0
  6. package/dist/canResizeImage.js.map +1 -0
  7. package/dist/createSharpFromFile.d.ts +8 -0
  8. package/dist/createSharpFromFile.d.ts.map +1 -0
  9. package/dist/createSharpFromFile.js +31 -0
  10. package/dist/createSharpFromFile.js.map +1 -0
  11. package/dist/createSharpFromFile.spec.js +120 -0
  12. package/dist/createSharpFromFile.spec.js.map +1 -0
  13. package/dist/getImageResizeAction.d.ts +24 -0
  14. package/dist/getImageResizeAction.d.ts.map +1 -0
  15. package/dist/getImageResizeAction.js +56 -0
  16. package/dist/getImageResizeAction.js.map +1 -0
  17. package/dist/handleRequest.d.ts +14 -0
  18. package/dist/handleRequest.d.ts.map +1 -0
  19. package/dist/handleRequest.js +143 -0
  20. package/dist/handleRequest.js.map +1 -0
  21. package/dist/handleRequest.spec.js +188 -0
  22. package/dist/handleRequest.spec.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +3 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/initSharpCollections.d.ts +14 -0
  28. package/dist/initSharpCollections.d.ts.map +1 -0
  29. package/dist/initSharpCollections.js +84 -0
  30. package/dist/initSharpCollections.js.map +1 -0
  31. package/dist/initSharpCollections.spec.js +185 -0
  32. package/dist/initSharpCollections.spec.js.map +1 -0
  33. package/dist/mapWithBoundedConcurrency.d.ts +7 -0
  34. package/dist/mapWithBoundedConcurrency.d.ts.map +1 -0
  35. package/dist/mapWithBoundedConcurrency.js +26 -0
  36. package/dist/mapWithBoundedConcurrency.js.map +1 -0
  37. package/dist/mapWithBoundedConcurrency.spec.js +35 -0
  38. package/dist/mapWithBoundedConcurrency.spec.js.map +1 -0
  39. package/dist/optionallyAppendMetadata.d.ts +9 -0
  40. package/dist/optionallyAppendMetadata.d.ts.map +1 -0
  41. package/dist/optionallyAppendMetadata.js +17 -0
  42. package/dist/optionallyAppendMetadata.js.map +1 -0
  43. package/dist/parseDynamicResize.d.ts +17 -0
  44. package/dist/parseDynamicResize.d.ts.map +1 -0
  45. package/dist/parseDynamicResize.js +117 -0
  46. package/dist/parseDynamicResize.js.map +1 -0
  47. package/dist/parseDynamicResize.spec.js +123 -0
  48. package/dist/parseDynamicResize.spec.js.map +1 -0
  49. package/dist/prepareLegacyUpload.d.ts +14 -0
  50. package/dist/prepareLegacyUpload.d.ts.map +1 -0
  51. package/dist/prepareLegacyUpload.js +147 -0
  52. package/dist/prepareLegacyUpload.js.map +1 -0
  53. package/dist/prepareLegacyUpload.spec.js +95 -0
  54. package/dist/prepareLegacyUpload.spec.js.map +1 -0
  55. package/dist/sanitizeResizeConfig.d.ts +11 -0
  56. package/dist/sanitizeResizeConfig.d.ts.map +1 -0
  57. package/dist/sanitizeResizeConfig.js +20 -0
  58. package/dist/sanitizeResizeConfig.js.map +1 -0
  59. package/dist/sharpTransformer.d.ts +10 -0
  60. package/dist/sharpTransformer.d.ts.map +1 -0
  61. package/dist/sharpTransformer.js +122 -0
  62. package/dist/sharpTransformer.js.map +1 -0
  63. package/dist/sharpTransformer.spec.js +117 -0
  64. package/dist/sharpTransformer.spec.js.map +1 -0
  65. package/dist/transformFile.d.ts +12 -0
  66. package/dist/transformFile.d.ts.map +1 -0
  67. package/dist/transformFile.js +264 -0
  68. package/dist/transformFile.js.map +1 -0
  69. package/dist/transformFile.spec.js +259 -0
  70. package/dist/transformFile.spec.js.map +1 -0
  71. package/dist/types.d.ts +150 -0
  72. package/dist/types.d.ts.map +1 -0
  73. package/dist/types.js +7 -0
  74. package/dist/types.js.map +1 -0
  75. package/package.json +56 -0
@@ -0,0 +1,259 @@
1
+ import sharp from 'sharp';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { createTransformFile } from './transformFile.js';
4
+ const makeReq = ()=>({});
5
+ const toBuffer = async (file)=>Buffer.from(await file.arrayBuffer());
6
+ const makeImageBuffer = async ({ background = {
7
+ b: 0,
8
+ g: 128,
9
+ r: 255
10
+ }, height, width })=>sharp({
11
+ create: {
12
+ background,
13
+ channels: 3,
14
+ height,
15
+ width
16
+ }
17
+ }).png().toBuffer();
18
+ /**
19
+ * A two-colour image split along `splitAxis` (red/blue halves) — proves the
20
+ * focal-point extract region in `transformSize` lands where the math says,
21
+ * not just that the output dimensions are right.
22
+ */ const makeTwoColorImage = async ({ height, splitAxis, width })=>{
23
+ const raw = Buffer.alloc(width * height * 3);
24
+ for(let y = 0; y < height; y++){
25
+ for(let x = 0; x < width; x++){
26
+ const idx = (y * width + x) * 3;
27
+ const isFirstHalf = splitAxis === 'x' ? x < width / 2 : y < height / 2;
28
+ if (isFirstHalf) {
29
+ raw[idx] = 255; // red
30
+ } else {
31
+ raw[idx + 2] = 255; // blue
32
+ }
33
+ }
34
+ }
35
+ return sharp(raw, {
36
+ raw: {
37
+ channels: 3,
38
+ height,
39
+ width
40
+ }
41
+ }).png().toBuffer();
42
+ };
43
+ const sampleRawPixel = ({ data, info, x, y })=>{
44
+ const idx = (y * info.width + x) * info.channels;
45
+ return {
46
+ b: data[idx + 2],
47
+ g: data[idx + 1],
48
+ r: data[idx]
49
+ };
50
+ };
51
+ describe('createTransformFile', ()=>{
52
+ describe('main (transformMain)', ()=>{
53
+ it('should trim uniform-colour padding from the main file', async ()=>{
54
+ const square = await makeImageBuffer({
55
+ background: {
56
+ b: 0,
57
+ g: 0,
58
+ r: 0
59
+ },
60
+ height: 20,
61
+ width: 20
62
+ });
63
+ const framed = await sharp({
64
+ create: {
65
+ background: {
66
+ b: 255,
67
+ g: 255,
68
+ r: 255
69
+ },
70
+ channels: 3,
71
+ height: 60,
72
+ width: 60
73
+ }
74
+ }).composite([
75
+ {
76
+ input: square,
77
+ left: 20,
78
+ top: 20
79
+ }
80
+ ]).png().toBuffer();
81
+ const file = new File([
82
+ framed
83
+ ], 'photo.png', {
84
+ type: 'image/png'
85
+ });
86
+ const transformFile = createTransformFile({
87
+ sharpDependency: sharp
88
+ });
89
+ const result = await transformFile({
90
+ file,
91
+ options: {
92
+ collectionUpload: {
93
+ trimOptions: {}
94
+ },
95
+ kind: 'main'
96
+ },
97
+ req: makeReq()
98
+ });
99
+ const metadata = await sharp(await toBuffer(result.file)).metadata();
100
+ expect(metadata.width).toBe(20);
101
+ expect(metadata.height).toBe(20);
102
+ });
103
+ it.each([
104
+ // Re-applied by default, so the 40x40 crop is resized down to 20x20.
105
+ {
106
+ expectedSize: 20,
107
+ resizeOptions: {
108
+ fit: 'cover',
109
+ height: 20,
110
+ width: 20
111
+ }
112
+ },
113
+ {
114
+ expectedSize: 40,
115
+ resizeOptions: {
116
+ height: 20,
117
+ width: 20,
118
+ withoutEnlargement: true
119
+ }
120
+ }
121
+ ])('should re-apply resizeOptions to the crop output unless withoutEnlargement is set (%#)', async ({ expectedSize, resizeOptions })=>{
122
+ const buffer = await makeImageBuffer({
123
+ height: 100,
124
+ width: 100
125
+ });
126
+ const file = new File([
127
+ buffer
128
+ ], 'photo.png', {
129
+ type: 'image/png'
130
+ });
131
+ const transformFile = createTransformFile({
132
+ sharpDependency: sharp
133
+ });
134
+ const result = await transformFile({
135
+ file,
136
+ options: {
137
+ collectionUpload: {
138
+ resizeOptions
139
+ },
140
+ crop: {
141
+ cropData: {
142
+ height: 40,
143
+ unit: '%',
144
+ width: 40,
145
+ x: 25,
146
+ y: 25
147
+ },
148
+ heightInPixels: 40,
149
+ originalDimensions: {
150
+ height: 100,
151
+ width: 100
152
+ },
153
+ widthInPixels: 40
154
+ },
155
+ kind: 'main'
156
+ },
157
+ req: makeReq()
158
+ });
159
+ const metadata = await sharp(await toBuffer(result.file)).metadata();
160
+ expect(metadata.width).toBe(expectedSize);
161
+ expect(metadata.height).toBe(expectedSize);
162
+ });
163
+ });
164
+ describe('size (transformSize)', ()=>{
165
+ // Each original forces one resize-priority branch, and a focal point at 80% pushes the
166
+ // 50px extract window against the clamped far edge, so a correct crop is entirely blue.
167
+ it.each([
168
+ {
169
+ focalPoint: {
170
+ x: 80,
171
+ y: 50
172
+ },
173
+ original: {
174
+ height: 100,
175
+ splitAxis: 'x',
176
+ width: 200
177
+ },
178
+ samples: [
179
+ {
180
+ x: 10,
181
+ y: 25
182
+ },
183
+ {
184
+ x: 40,
185
+ y: 25
186
+ }
187
+ ]
188
+ },
189
+ {
190
+ focalPoint: {
191
+ x: 50,
192
+ y: 80
193
+ },
194
+ original: {
195
+ height: 200,
196
+ splitAxis: 'y',
197
+ width: 100
198
+ },
199
+ samples: [
200
+ {
201
+ x: 25,
202
+ y: 10
203
+ },
204
+ {
205
+ x: 25,
206
+ y: 40
207
+ }
208
+ ]
209
+ }
210
+ ])('should extract the focal-point region along the $original.splitAxis axis', async ({ focalPoint, original, samples })=>{
211
+ const buffer = await makeTwoColorImage(original);
212
+ const file = new File([
213
+ buffer
214
+ ], 'photo.png', {
215
+ type: 'image/png'
216
+ });
217
+ const transformFile = createTransformFile({
218
+ sharpDependency: sharp
219
+ });
220
+ const result = await transformFile({
221
+ file,
222
+ options: {
223
+ collectionUpload: {},
224
+ focalPoint,
225
+ imageResizeConfig: {
226
+ name: 'thumb',
227
+ height: 50,
228
+ width: 50
229
+ },
230
+ kind: 'size',
231
+ originalDimensions: {
232
+ height: original.height,
233
+ width: original.width
234
+ }
235
+ },
236
+ req: makeReq()
237
+ });
238
+ const { data, info } = await sharp(await toBuffer(result.file)).raw().toBuffer({
239
+ resolveWithObject: true
240
+ });
241
+ expect(info.width).toBe(50);
242
+ expect(info.height).toBe(50);
243
+ for (const { x, y } of samples){
244
+ expect(sampleRawPixel({
245
+ data,
246
+ info,
247
+ x,
248
+ y
249
+ })).toEqual({
250
+ b: 255,
251
+ g: 0,
252
+ r: 0
253
+ });
254
+ }
255
+ });
256
+ });
257
+ });
258
+
259
+ //# sourceMappingURL=transformFile.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/transformFile.spec.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport sharp from 'sharp'\nimport { describe, expect, it } from 'vitest'\n\nimport type { SharpUploadTaskOptions } from './types.js'\n\nimport { createTransformFile } from './transformFile.js'\n\nconst makeReq = (): PayloadRequest => ({}) as PayloadRequest\n\nconst toBuffer = async (file: File): Promise<Buffer> => Buffer.from(await file.arrayBuffer())\n\nconst makeImageBuffer = async ({\n background = { b: 0, g: 128, r: 255 },\n height,\n width,\n}: {\n background?: { b: number; g: number; r: number }\n height: number\n width: number\n}): Promise<Buffer> =>\n sharp({ create: { background, channels: 3, height, width } })\n .png()\n .toBuffer()\n\n/**\n * A two-colour image split along `splitAxis` (red/blue halves) — proves the\n * focal-point extract region in `transformSize` lands where the math says,\n * not just that the output dimensions are right.\n */\nconst makeTwoColorImage = async ({\n height,\n splitAxis,\n width,\n}: {\n height: number\n splitAxis: 'x' | 'y'\n width: number\n}): Promise<Buffer> => {\n const raw = Buffer.alloc(width * height * 3)\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n const idx = (y * width + x) * 3\n const isFirstHalf = splitAxis === 'x' ? x < width / 2 : y < height / 2\n\n if (isFirstHalf) {\n raw[idx] = 255 // red\n } else {\n raw[idx + 2] = 255 // blue\n }\n }\n }\n\n return sharp(raw, { raw: { channels: 3, height, width } })\n .png()\n .toBuffer()\n}\n\nconst sampleRawPixel = ({\n data,\n info,\n x,\n y,\n}: {\n data: Buffer\n info: { channels: number; width: number }\n x: number\n y: number\n}): { b: number; g: number; r: number } => {\n const idx = (y * info.width + x) * info.channels\n return { b: data[idx + 2]!, g: data[idx + 1]!, r: data[idx]! }\n}\n\ndescribe('createTransformFile', () => {\n describe('main (transformMain)', () => {\n it('should trim uniform-colour padding from the main file', async () => {\n const square = await makeImageBuffer({\n background: { b: 0, g: 0, r: 0 },\n height: 20,\n width: 20,\n })\n const framed = await sharp({\n create: { background: { b: 255, g: 255, r: 255 }, channels: 3, height: 60, width: 60 },\n })\n .composite([{ input: square, left: 20, top: 20 }])\n .png()\n .toBuffer()\n const file = new File([framed], 'photo.png', { type: 'image/png' })\n const transformFile = createTransformFile({ sharpDependency: sharp })\n\n const result = await transformFile({\n file,\n options: {\n collectionUpload: { trimOptions: {} },\n kind: 'main',\n } satisfies SharpUploadTaskOptions,\n req: makeReq(),\n })\n\n const metadata = await sharp(await toBuffer(result.file!)).metadata()\n expect(metadata.width).toBe(20)\n expect(metadata.height).toBe(20)\n })\n\n it.each([\n // Re-applied by default, so the 40x40 crop is resized down to 20x20.\n { expectedSize: 20, resizeOptions: { fit: 'cover' as const, height: 20, width: 20 } },\n { expectedSize: 40, resizeOptions: { height: 20, width: 20, withoutEnlargement: true } },\n ])(\n 'should re-apply resizeOptions to the crop output unless withoutEnlargement is set (%#)',\n async ({ expectedSize, resizeOptions }) => {\n const buffer = await makeImageBuffer({ height: 100, width: 100 })\n const file = new File([buffer], 'photo.png', { type: 'image/png' })\n const transformFile = createTransformFile({ sharpDependency: sharp })\n\n const result = await transformFile({\n file,\n options: {\n collectionUpload: { resizeOptions },\n crop: {\n cropData: { height: 40, unit: '%', width: 40, x: 25, y: 25 },\n heightInPixels: 40,\n originalDimensions: { height: 100, width: 100 },\n widthInPixels: 40,\n },\n kind: 'main',\n } satisfies SharpUploadTaskOptions,\n req: makeReq(),\n })\n\n const metadata = await sharp(await toBuffer(result.file!)).metadata()\n expect(metadata.width).toBe(expectedSize)\n expect(metadata.height).toBe(expectedSize)\n },\n )\n })\n\n describe('size (transformSize)', () => {\n // Each original forces one resize-priority branch, and a focal point at 80% pushes the\n // 50px extract window against the clamped far edge, so a correct crop is entirely blue.\n it.each([\n {\n focalPoint: { x: 80, y: 50 },\n original: { height: 100, splitAxis: 'x' as const, width: 200 },\n samples: [\n { x: 10, y: 25 },\n { x: 40, y: 25 },\n ],\n },\n {\n focalPoint: { x: 50, y: 80 },\n original: { height: 200, splitAxis: 'y' as const, width: 100 },\n samples: [\n { x: 25, y: 10 },\n { x: 25, y: 40 },\n ],\n },\n ])(\n 'should extract the focal-point region along the $original.splitAxis axis',\n async ({ focalPoint, original, samples }) => {\n const buffer = await makeTwoColorImage(original)\n const file = new File([buffer], 'photo.png', { type: 'image/png' })\n const transformFile = createTransformFile({ sharpDependency: sharp })\n\n const result = await transformFile({\n file,\n options: {\n collectionUpload: {},\n focalPoint,\n imageResizeConfig: { name: 'thumb', height: 50, width: 50 },\n kind: 'size',\n originalDimensions: { height: original.height, width: original.width },\n } satisfies SharpUploadTaskOptions,\n req: makeReq(),\n })\n\n const { data, info } = await sharp(await toBuffer(result.file!))\n .raw()\n .toBuffer({ resolveWithObject: true })\n expect(info.width).toBe(50)\n expect(info.height).toBe(50)\n for (const { x, y } of samples) {\n expect(sampleRawPixel({ data, info, x, y })).toEqual({ b: 255, g: 0, r: 0 })\n }\n },\n )\n })\n})\n"],"names":["sharp","describe","expect","it","createTransformFile","makeReq","toBuffer","file","Buffer","from","arrayBuffer","makeImageBuffer","background","b","g","r","height","width","create","channels","png","makeTwoColorImage","splitAxis","raw","alloc","y","x","idx","isFirstHalf","sampleRawPixel","data","info","square","framed","composite","input","left","top","File","type","transformFile","sharpDependency","result","options","collectionUpload","trimOptions","kind","req","metadata","toBe","each","expectedSize","resizeOptions","fit","withoutEnlargement","buffer","crop","cropData","unit","heightInPixels","originalDimensions","widthInPixels","focalPoint","original","samples","imageResizeConfig","name","resolveWithObject","toEqual"],"mappings":"AAEA,OAAOA,WAAW,QAAO;AACzB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAI7C,SAASC,mBAAmB,QAAQ,qBAAoB;AAExD,MAAMC,UAAU,IAAuB,CAAA,CAAC,CAAA;AAExC,MAAMC,WAAW,OAAOC,OAAgCC,OAAOC,IAAI,CAAC,MAAMF,KAAKG,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AEC,GAAG;wBAAID,GAAG;oBAAG;iBAChB;YACH;SACD,EACC,4EACA,OAAO,EAAEqC,UAAU,EAAEC,QAAQ,EAAEC,OAAO,EAAE;YACtC,MAAMT,SAAS,MAAMlC,kBAAkB0C;YACvC,MAAMxD,OAAO,IAAI+B,KAAK;gBAACiB;aAAO,EAAE,aAAa;gBAAEhB,MAAM;YAAY;YACjE,MAAMC,gBAAgBpC,oBAAoB;gBAAEqC,iBAAiBzC;YAAM;YAEnE,MAAM0C,SAAS,MAAMF,cAAc;gBACjCjC;gBACAoC,SAAS;oBACPC,kBAAkB,CAAC;oBACnBkB;oBACAG,mBAAmB;wBAAEC,MAAM;wBAASlD,QAAQ;wBAAIC,OAAO;oBAAG;oBAC1D6B,MAAM;oBACNc,oBAAoB;wBAAE5C,QAAQ+C,SAAS/C,MAAM;wBAAEC,OAAO8C,SAAS9C,KAAK;oBAAC;gBACvE;gBACA8B,KAAK1C;YACP;YAEA,MAAM,EAAEyB,IAAI,EAAEC,IAAI,EAAE,GAAG,MAAM/B,MAAM,MAAMM,SAASoC,OAAOnC,IAAI,GAC1DgB,GAAG,GACHjB,QAAQ,CAAC;gBAAE6D,mBAAmB;YAAK;YACtCjE,OAAO6B,KAAKd,KAAK,EAAEgC,IAAI,CAAC;YACxB/C,OAAO6B,KAAKf,MAAM,EAAEiC,IAAI,CAAC;YACzB,KAAK,MAAM,EAAEvB,CAAC,EAAED,CAAC,EAAE,IAAIuC,QAAS;gBAC9B9D,OAAO2B,eAAe;oBAAEC;oBAAMC;oBAAML;oBAAGD;gBAAE,IAAI2C,OAAO,CAAC;oBAAEvD,GAAG;oBAAKC,GAAG;oBAAGC,GAAG;gBAAE;YAC5E;QACF;IAEJ;AACF"}
@@ -0,0 +1,150 @@
1
+ import type { FocalPoint, ImageSize, PayloadRequest, ProbedImageSize, UploadCollectionSlug, UploadEdits } from 'payload';
2
+ import type { FitEnum, ResizeOptions, Sharp, Metadata as SharpMetadata, SharpOptions } from 'sharp';
3
+ /**
4
+ * Params sent to the sharp `toFormat()` function
5
+ * @link https://sharp.pixelplumbing.com/api-output#toformat
6
+ */
7
+ export type ImageUploadFormatOptions = {
8
+ format: Parameters<Sharp['toFormat']>[0];
9
+ options?: Parameters<Sharp['toFormat']>[1];
10
+ };
11
+ /**
12
+ * Params sent to the sharp trim() function
13
+ * @link https://sharp.pixelplumbing.com/api-resize#trim
14
+ */
15
+ export type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0];
16
+ export type WithMetadata = ((options: {
17
+ metadata: SharpMetadata;
18
+ req: PayloadRequest;
19
+ }) => Promise<boolean>) | boolean;
20
+ /**
21
+ * Image size options implemented by Payload's default Sharp image processor.
22
+ */
23
+ export type SharpImageSizeOptions = {
24
+ /**
25
+ * @deprecated prefer position
26
+ */
27
+ crop?: string;
28
+ formatOptions?: ImageUploadFormatOptions;
29
+ trimOptions?: ImageUploadTrimOptions;
30
+ /** Image sizes generated for each upload, stored under the document's `variants`. */
31
+ variants?: ImageSize[];
32
+ /**
33
+ * When an uploaded image is smaller than the defined image size, we have 3 options:
34
+ *
35
+ * `undefined | false | true`
36
+ *
37
+ * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null
38
+ * 2. `false`: always enlarge images to the image size
39
+ * 3. `true`: if the image is smaller than the image size, return the original image
40
+ */
41
+ withoutEnlargement?: ResizeOptions['withoutEnlargement'];
42
+ } & Omit<ResizeOptions, 'withoutEnlargement'>;
43
+ declare module 'payload' {
44
+ interface RegisteredImageSizeOptions {
45
+ sharp: SharpImageSizeOptions;
46
+ }
47
+ }
48
+ /**
49
+ * A collection's Sharp-owned upload-time settings, authored via
50
+ * `sharpTransformer({ collections: { <slug>: {...} } })`. `init()` writes a
51
+ * narrowed, Sharp-agnostic projection of `variants`/`crop`/`focalPoint`
52
+ * back onto the sanitized collection's `upload` config for core's own use (Admin UI,
53
+ * field generation); this richer shape is what the transformer itself reads.
54
+ */
55
+ export type SharpCollectionConfig = {
56
+ constructorOptions?: SharpOptions;
57
+ crop?: boolean;
58
+ focalPoint?: boolean;
59
+ formatOptions?: ImageUploadFormatOptions;
60
+ resizeOptions?: ResizeOptions;
61
+ trimOptions?: ImageUploadTrimOptions;
62
+ /** Image sizes generated for each upload, stored under the document's `variants`. */
63
+ variants?: ImageSize[];
64
+ withMetadata?: WithMetadata;
65
+ };
66
+ /**
67
+ * Matches core's (soon-removed) `SharpDependency` shape, for advanced injection
68
+ * of a compatible custom Sharp build or version via `sharpTransformer({ sharp })`.
69
+ */
70
+ export type SharpDependency = (input?: ArrayBuffer | Buffer | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | string | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array, options?: SharpOptions) => Sharp;
71
+ export type SharpDynamicDefaults = {
72
+ /** @default 'cover' */
73
+ fit?: keyof FitEnum;
74
+ /** @default 4096 */
75
+ maxHeight?: number;
76
+ /**
77
+ * Total output pixels, counted across every frame of an animated image.
78
+ * @default 16_777_216
79
+ */
80
+ maxPixels?: number;
81
+ /** @default 4096 */
82
+ maxWidth?: number;
83
+ /** @default 'center' */
84
+ position?: ResizeOptions['position'];
85
+ /** @default false */
86
+ withoutEnlargement?: boolean;
87
+ };
88
+ /**
89
+ * Enables request-time resizing and tunes its limits. `collections` restricts it
90
+ * to the listed upload collections; omit it to allow every upload collection.
91
+ */
92
+ export type SharpDynamicOptions = {
93
+ collections?: UploadCollectionSlug[];
94
+ } & SharpDynamicDefaults;
95
+ /**
96
+ * The result of parsing a request's dynamic resize query parameters.
97
+ * `isRouted: false` means none of the recognized parameters were present at
98
+ * all — an ordinary file read, not a dynamic transformation attempt.
99
+ */
100
+ export type DynamicResizeParseResult = {
101
+ error: string;
102
+ isRouted: true;
103
+ valid: false;
104
+ } | {
105
+ height?: number;
106
+ isRouted: true;
107
+ valid: true;
108
+ width?: number;
109
+ withoutEnlargement?: boolean;
110
+ } | {
111
+ isRouted: false;
112
+ };
113
+ export type SharpTransformerOptions = {
114
+ /** Per-collection upload-time image processing settings. */
115
+ collections?: Partial<Record<UploadCollectionSlug, SharpCollectionConfig>>;
116
+ /**
117
+ * Request-time resizing via `?width=`/`?height=` on the file endpoint. `true`
118
+ * enables it with default limits for every upload collection; an object enables
119
+ * it with custom limits, optionally restricted to specific collections.
120
+ *
121
+ * @default false
122
+ */
123
+ dynamic?: boolean | SharpDynamicOptions;
124
+ /** Inject a compatible custom Sharp build or version. Defaults to the bundled dependency. */
125
+ sharp?: SharpDependency;
126
+ /** @default 'sharp' */
127
+ slug?: string;
128
+ };
129
+ /**
130
+ * `options` for the one-file-in/one-file-out `transformFile` primitive, computed
131
+ * by `prepareLegacyUpload` for each task it hands to the injected `transform`
132
+ * callback: the main file (optionally a crop), or one named legacy image size.
133
+ */
134
+ export type SharpUploadTaskOptions = {
135
+ collectionUpload: SharpCollectionConfig;
136
+ crop?: {
137
+ cropData: NonNullable<UploadEdits['crop']>;
138
+ heightInPixels: number;
139
+ originalDimensions: ProbedImageSize;
140
+ widthInPixels: number;
141
+ };
142
+ kind: 'main';
143
+ } | {
144
+ collectionUpload: SharpCollectionConfig;
145
+ focalPoint?: FocalPoint;
146
+ imageResizeConfig: ImageSize;
147
+ kind: 'size';
148
+ originalDimensions: ProbedImageSize;
149
+ };
150
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,WAAW,EACZ,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEnG;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;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A;IAC1E;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAA;IACvC,6FAA6F;IAC7F,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAC9B;IACE,gBAAgB,EAAE,qBAAqB,CAAA;IACvC,IAAI,CAAC,EAAE;QACL,QAAQ,EAAE,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,kBAAkB,EAAE,eAAe,CAAA;QACnC,aAAa,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,gBAAgB,EAAE,qBAAqB,CAAA;IACvC,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,iBAAiB,EAAE,SAAS,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,kBAAkB,EAAE,eAAe,CAAA;CACpC,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `options` for the one-file-in/one-file-out `transformFile` primitive, computed
3
+ * by `prepareLegacyUpload` for each task it hands to the injected `transform`
4
+ * callback: the main file (optionally a crop), or one named legacy image size.
5
+ */ export { };
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n FocalPoint,\n ImageSize,\n PayloadRequest,\n ProbedImageSize,\n UploadCollectionSlug,\n UploadEdits,\n} from 'payload'\nimport type { FitEnum, ResizeOptions, Sharp, Metadata as SharpMetadata, SharpOptions } from 'sharp'\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type WithMetadata =\n | ((options: { metadata: SharpMetadata; req: PayloadRequest }) => Promise<boolean>)\n | boolean\n\n/**\n * Image size options implemented by Payload's default Sharp image processor.\n */\nexport type SharpImageSizeOptions = {\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n trimOptions?: ImageUploadTrimOptions\n /** Image sizes generated for each upload, stored under the document's `variants`. */\n variants?: ImageSize[]\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\ndeclare module 'payload' {\n interface RegisteredImageSizeOptions {\n sharp: SharpImageSizeOptions\n }\n}\n\n/**\n * A collection's Sharp-owned upload-time settings, authored via\n * `sharpTransformer({ collections: { <slug>: {...} } })`. `init()` writes a\n * narrowed, Sharp-agnostic projection of `variants`/`crop`/`focalPoint`\n * back onto the sanitized collection's `upload` config for core's own use (Admin UI,\n * field generation); this richer shape is what the transformer itself reads.\n */\nexport type SharpCollectionConfig = {\n constructorOptions?: SharpOptions\n crop?: boolean\n focalPoint?: boolean\n formatOptions?: ImageUploadFormatOptions\n resizeOptions?: ResizeOptions\n trimOptions?: ImageUploadTrimOptions\n /** Image sizes generated for each upload, stored under the document's `variants`. */\n variants?: ImageSize[]\n withMetadata?: WithMetadata\n}\n\n/**\n * Matches core's (soon-removed) `SharpDependency` shape, for advanced injection\n * of a compatible custom Sharp build or version via `sharpTransformer({ sharp })`.\n */\nexport type SharpDependency = (\n input?:\n | ArrayBuffer\n | Buffer\n | Float32Array\n | Float64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | string\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array,\n options?: SharpOptions,\n) => Sharp\n\nexport type SharpDynamicDefaults = {\n /** @default 'cover' */\n fit?: keyof FitEnum\n /** @default 4096 */\n maxHeight?: number\n /**\n * Total output pixels, counted across every frame of an animated image.\n * @default 16_777_216\n */\n maxPixels?: number\n /** @default 4096 */\n maxWidth?: number\n /** @default 'center' */\n position?: ResizeOptions['position']\n /** @default false */\n withoutEnlargement?: boolean\n}\n\n/**\n * Enables request-time resizing and tunes its limits. `collections` restricts it\n * to the listed upload collections; omit it to allow every upload collection.\n */\nexport type SharpDynamicOptions = {\n collections?: UploadCollectionSlug[]\n} & SharpDynamicDefaults\n\n/**\n * The result of parsing a request's dynamic resize query parameters.\n * `isRouted: false` means none of the recognized parameters were present at\n * all — an ordinary file read, not a dynamic transformation attempt.\n */\nexport type DynamicResizeParseResult =\n | {\n error: string\n isRouted: true\n valid: false\n }\n | {\n height?: number\n isRouted: true\n valid: true\n width?: number\n withoutEnlargement?: boolean\n }\n | {\n isRouted: false\n }\n\nexport type SharpTransformerOptions = {\n /** Per-collection upload-time image processing settings. */\n collections?: Partial<Record<UploadCollectionSlug, SharpCollectionConfig>>\n /**\n * Request-time resizing via `?width=`/`?height=` on the file endpoint. `true`\n * enables it with default limits for every upload collection; an object enables\n * it with custom limits, optionally restricted to specific collections.\n *\n * @default false\n */\n dynamic?: boolean | SharpDynamicOptions\n /** Inject a compatible custom Sharp build or version. Defaults to the bundled dependency. */\n sharp?: SharpDependency\n /** @default 'sharp' */\n slug?: string\n}\n\n/**\n * `options` for the one-file-in/one-file-out `transformFile` primitive, computed\n * by `prepareLegacyUpload` for each task it hands to the injected `transform`\n * callback: the main file (optionally a crop), or one named legacy image size.\n */\nexport type SharpUploadTaskOptions =\n | {\n collectionUpload: SharpCollectionConfig\n crop?: {\n cropData: NonNullable<UploadEdits['crop']>\n heightInPixels: number\n originalDimensions: ProbedImageSize\n widthInPixels: number\n }\n kind: 'main'\n }\n | {\n collectionUpload: SharpCollectionConfig\n focalPoint?: FocalPoint\n imageResizeConfig: ImageSize\n kind: 'size'\n originalDimensions: ProbedImageSize\n }\n"],"names":[],"mappings":"AAoKA;;;;CAIC,GACD,WAiBK"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@payloadcms/transformer-sharp",
3
+ "version": "4.0.0-internal.58473b9",
4
+ "description": "Official Sharp-based file transformer for Payload: request-time image resizing and upload-time image processing",
5
+ "homepage": "https://payloadcms.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/payloadcms/payload.git",
9
+ "directory": "packages/transformer-sharp"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
13
+ "maintainers": [
14
+ {
15
+ "name": "Payload",
16
+ "email": "info@payloadcms.com",
17
+ "url": "https://payloadcms.com"
18
+ }
19
+ ],
20
+ "sideEffects": false,
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ },
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "dependencies": {
35
+ "sharp": "0.35.4"
36
+ },
37
+ "devDependencies": {
38
+ "payload": "4.0.0-internal.58473b9"
39
+ },
40
+ "peerDependencies": {
41
+ "payload": "4.0.0-internal.58473b9"
42
+ },
43
+ "engines": {
44
+ "node": ">=24.15.0"
45
+ },
46
+ "scripts": {
47
+ "build": "pnpm build:types && pnpm build:swc",
48
+ "build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
49
+ "build:debug": "pnpm build",
50
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
51
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
52
+ "clean": "rimraf -g {dist,*.tsbuildinfo}",
53
+ "lint": "eslint .",
54
+ "lint:fix": "eslint . --fix"
55
+ }
56
+ }