@m4k/common 0.2.2 → 0.2.4
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/lib/index.d.ts +18 -4
- package/lib/index.js +1 -0
- package/lib/mime.d.ts +5 -0
- package/lib/mime.js +52 -0
- package/package.json +8 -3
package/lib/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type QueuePosition = {
|
|
|
7
7
|
export type ProcessingError = {
|
|
8
8
|
error: string;
|
|
9
9
|
};
|
|
10
|
+
type ImageFormat = "avif" | "jpeg" | "png" | "webp" | "tiff" | "dz" | "ppm" | "fits" | "gif" | "svg" | "heif" | "pdf" | "jp2";
|
|
10
11
|
export type ImageOptions = {
|
|
11
12
|
/** The rotation of the image. If not provided, the image will be auto-rotated, according to the EXIF data. To disable auto-rotation, set to `0`. */
|
|
12
13
|
rotate?: number;
|
|
@@ -19,8 +20,10 @@ export type ImageOptions = {
|
|
|
19
20
|
/** The way to resize the image. */
|
|
20
21
|
fit?: "contain" | "cover" | "fill" | "inside" | "outside";
|
|
21
22
|
};
|
|
23
|
+
/** The extension of the output file. This is the same as the format. */
|
|
24
|
+
ext?: ImageFormat;
|
|
22
25
|
/** The format of the output file. */
|
|
23
|
-
format?:
|
|
26
|
+
format?: ImageFormat;
|
|
24
27
|
/** The quality of the output file. */
|
|
25
28
|
quality?: number;
|
|
26
29
|
/** Whether to keep the metadata of the image. */
|
|
@@ -42,9 +45,11 @@ export type ImageOptions = {
|
|
|
42
45
|
/** The height of the crop. */
|
|
43
46
|
height: number;
|
|
44
47
|
};
|
|
48
|
+
};
|
|
49
|
+
export type RemoteImageOptions = ImageOptions & {
|
|
45
50
|
/** The name of the output file. */
|
|
46
51
|
name?: string;
|
|
47
|
-
/** The output path of the file. */
|
|
52
|
+
/** The output path of the file. This can be a local path or an S3 path. */
|
|
48
53
|
output?: string;
|
|
49
54
|
};
|
|
50
55
|
export type VideoOptions = {
|
|
@@ -82,9 +87,13 @@ export type VideoOptions = {
|
|
|
82
87
|
videoCodec?: string;
|
|
83
88
|
/** The filters to apply to the video. */
|
|
84
89
|
videoFilters?: string;
|
|
90
|
+
/** Custom ffmpeg arguments to apply to this video processing. */
|
|
91
|
+
args?: string[];
|
|
92
|
+
};
|
|
93
|
+
export type RemoteVideoOptions = VideoOptions & {
|
|
85
94
|
/** The name of the output file. */
|
|
86
95
|
name?: string;
|
|
87
|
-
/** The output path of the file. */
|
|
96
|
+
/** The output path of the file. This can be a local path or an S3 path. */
|
|
88
97
|
output?: string;
|
|
89
98
|
};
|
|
90
99
|
export type AudioOptions = {
|
|
@@ -106,9 +115,13 @@ export type AudioOptions = {
|
|
|
106
115
|
inputFormat?: string;
|
|
107
116
|
/** The seek time of the audio. */
|
|
108
117
|
seek?: number | string;
|
|
118
|
+
/** Custom ffmpeg arguments to apply to this audio processing. */
|
|
119
|
+
args?: string[];
|
|
120
|
+
};
|
|
121
|
+
export type RemoteAudioOptions = AudioOptions & {
|
|
109
122
|
/** The name of the output file. */
|
|
110
123
|
name?: string;
|
|
111
|
-
/** The output path of the file. */
|
|
124
|
+
/** The output path of the file. This can be a local path or an S3 path. */
|
|
112
125
|
output?: string;
|
|
113
126
|
};
|
|
114
127
|
export declare class ProcessedFile {
|
|
@@ -117,4 +130,5 @@ export declare class ProcessedFile {
|
|
|
117
130
|
readonly stream?: AsyncIterable<Uint8Array> | undefined;
|
|
118
131
|
constructor(name: string, type: string, stream?: AsyncIterable<Uint8Array> | undefined);
|
|
119
132
|
}
|
|
133
|
+
export { mimeTypes } from "./mime";
|
|
120
134
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
package/lib/mime.d.ts
ADDED
package/lib/mime.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapping from file extensions to their corresponding MIME types
|
|
3
|
+
*/
|
|
4
|
+
export const mimeTypes = {
|
|
5
|
+
// Image formats
|
|
6
|
+
jpg: "image/jpeg",
|
|
7
|
+
jpeg: "image/jpeg",
|
|
8
|
+
png: "image/png",
|
|
9
|
+
gif: "image/gif",
|
|
10
|
+
webp: "image/webp",
|
|
11
|
+
avif: "image/avif",
|
|
12
|
+
heic: "image/heic",
|
|
13
|
+
heif: "image/heif",
|
|
14
|
+
svg: "image/svg+xml",
|
|
15
|
+
tiff: "image/tiff",
|
|
16
|
+
tif: "image/tiff",
|
|
17
|
+
bmp: "image/bmp",
|
|
18
|
+
ico: "image/x-icon",
|
|
19
|
+
// Video formats
|
|
20
|
+
mp4: "video/mp4",
|
|
21
|
+
asx: "video/x-ms-asf",
|
|
22
|
+
asf: "video/x-ms-asf",
|
|
23
|
+
mkv: "video/x-matroska",
|
|
24
|
+
mov: "video/quicktime",
|
|
25
|
+
avi: "video/x-msvideo",
|
|
26
|
+
wmv: "video/x-ms-wmv",
|
|
27
|
+
flv: "video/x-flv",
|
|
28
|
+
webm: "video/webm",
|
|
29
|
+
m4v: "video/x-m4v",
|
|
30
|
+
mng: "video/x-mng",
|
|
31
|
+
mpg: "video/mpeg",
|
|
32
|
+
mpeg: "video/mpeg",
|
|
33
|
+
ogv: "video/ogg",
|
|
34
|
+
"3gpp": "video/3gpp",
|
|
35
|
+
"3gp": "video/3gpp",
|
|
36
|
+
ts: "video/mp2t",
|
|
37
|
+
// Audio formats
|
|
38
|
+
mp3: "audio/mpeg",
|
|
39
|
+
wav: "audio/wav",
|
|
40
|
+
ogg: "audio/ogg",
|
|
41
|
+
oga: "audio/ogg",
|
|
42
|
+
m4a: "audio/mp4",
|
|
43
|
+
aac: "audio/aac",
|
|
44
|
+
flac: "audio/flac",
|
|
45
|
+
wma: "audio/x-ms-wma",
|
|
46
|
+
m4b: "audio/mp4",
|
|
47
|
+
m4p: "audio/mp4",
|
|
48
|
+
opus: "audio/opus",
|
|
49
|
+
aiff: "audio/aiff",
|
|
50
|
+
alac: "audio/alac",
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=mime.js.map
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4k/common",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"module": "./lib/index.js",
|
|
8
8
|
"license": "MIT",
|
|
9
|
+
"description": "Common types and utilities for m4k",
|
|
10
|
+
"author": "sv2dev",
|
|
9
11
|
"scripts": {
|
|
10
12
|
"prepublishOnly": "bun run build",
|
|
11
13
|
"build": "tsc -b",
|
|
12
14
|
"typecheck": "tsc --noEmit"
|
|
13
15
|
},
|
|
14
16
|
"devDependencies": {
|
|
15
|
-
"typescript": "^5.
|
|
17
|
+
"typescript": "^5.8.3"
|
|
16
18
|
},
|
|
17
|
-
"repository":
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/sv2dev/m4k.git"
|
|
22
|
+
}
|
|
18
23
|
}
|