File size: 876 Bytes
ee826ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Sharp stub for HF Spaces — provides enough API surface for yt-publisher.js
// to not crash. Thumbnail generation will silently fail (no-op).

function sharpStub(input) {
  return {
    png: () => sharpStub(),
    jpeg: (opts) => sharpStub(),
    toBuffer: async () => Buffer.alloc(0),
    toFile: async () => {},
    composite: (layers) => sharpStub(),
    resize: (w, h, opts) => sharpStub(),
    metadata: async () => ({ width: 1280, height: 720, format: 'png' }),
    raw: () => sharpStub(),
    extend: (opts) => sharpStub(),
    flatten: (opts) => sharpStub(),
    grayscale: () => sharpStub(),
    modulate: (opts) => sharpStub(),
  };
}

sharpStub.cache = () => sharpStub;
sharpStub.concurrency = () => 1;
sharpStub.simd = () => sharpStub;
sharpStub.format = { jpeg: true, png: true, webp: true };
sharpStub.versions = { vips: 'stub' };

export default sharpStub;