@travetto/image 5.0.0-rc.11 → 5.0.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/util.ts +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/image",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.12",
|
|
4
4
|
"description": "Image support, resizing, and optimization",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"images",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"directory": "module/image"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/command": "^5.0.0-rc.
|
|
27
|
-
"@travetto/runtime": "^5.0.0-rc.
|
|
26
|
+
"@travetto/command": "^5.0.0-rc.11",
|
|
27
|
+
"@travetto/runtime": "^5.0.0-rc.11",
|
|
28
28
|
"sharp": "^0.33.4"
|
|
29
29
|
},
|
|
30
30
|
"travetto": {
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
import { ReadableStream } from 'node:stream/web';
|
|
2
3
|
import { pipeline } from 'node:stream/promises';
|
|
3
4
|
import { buffer as toBuffer } from 'node:stream/consumers';
|
|
4
5
|
import { ChildProcess } from 'node:child_process';
|
|
@@ -46,7 +47,7 @@ export interface OptimizeOptions {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
|
|
49
|
-
type ImageType = Readable | Buffer;
|
|
50
|
+
type ImageType = Readable | Buffer | ReadableStream;
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* Simple support for image manipulation.
|
|
@@ -85,8 +86,8 @@ export class ImageUtil {
|
|
|
85
86
|
]);
|
|
86
87
|
return castTo(buffer);
|
|
87
88
|
} else {
|
|
88
|
-
pipeline(input, proc.stdin!);
|
|
89
|
-
return castTo(proc.stdout);
|
|
89
|
+
pipeline(castTo<Readable>(input), proc.stdin!);
|
|
90
|
+
return castTo('pipeThrough' in input ? ReadableStream.from(proc.stdout!) : proc.stdout);
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -98,7 +99,7 @@ export class ImageUtil {
|
|
|
98
99
|
}
|
|
99
100
|
const stream = Buffer.isBuffer(input) ? Readable.from(input) : input;
|
|
100
101
|
pipeline(stream, output);
|
|
101
|
-
return castTo(Buffer.isBuffer(input) ? output.toBuffer() : output);
|
|
102
|
+
return castTo('pipeThrough' in input ? ReadableStream.from(output) : Buffer.isBuffer(input) ? output.toBuffer() : output);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
/**
|