next-image-transformer 0.3.0 → 1.0.1
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/README.md +6 -11
- package/dist/createImageUrlBuilder.d.ts +9 -21
- package/dist/createImageUrlCodec-CIiY-UWp.js +11103 -0
- package/dist/createImageUrlCodec.d.ts +21 -0
- package/dist/index.js +5 -4
- package/dist/searchParamsToTransformConfigCodec.d.ts +2 -2
- package/dist/server.js +130 -192
- package/dist/transformConfigSchema.d.ts +2 -2
- package/package.json +9 -9
- package/dist/index-mUKn0C6P.js +0 -10259
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ import { imageUrlBuilder } from "../lib/imageUrlBuilder";
|
|
|
71
71
|
export function MyImage() {
|
|
72
72
|
return (
|
|
73
73
|
<img
|
|
74
|
-
src={imageUrlBuilder
|
|
74
|
+
src={imageUrlBuilder({
|
|
75
75
|
source: "https://images.example.com/cat.jpg",
|
|
76
76
|
fmt: "webp",
|
|
77
77
|
w: 800,
|
|
@@ -122,10 +122,7 @@ Returns: `(req: Request) => Promise<Response>` (compatible with Next.js Route Ha
|
|
|
122
122
|
|
|
123
123
|
Import from: `next-image-transformer`
|
|
124
124
|
|
|
125
|
-
Returns: a
|
|
126
|
-
|
|
127
|
-
- `encode(config: TransformConfig): string` (builds a URL)
|
|
128
|
-
- `safeDecode(url: string): { data?: TransformConfig; error?: ... }` (parses a URL)
|
|
125
|
+
Returns: a function `(config: TransformConfig) => string` that builds a transform URL.
|
|
129
126
|
|
|
130
127
|
**Options**
|
|
131
128
|
|
|
@@ -139,20 +136,18 @@ The transform URL uses these query params:
|
|
|
139
136
|
|
|
140
137
|
- **`source`**: `string` (required)
|
|
141
138
|
- Absolute `http(s)` URL to the upstream image.
|
|
142
|
-
- **`fmt`**: `"preserve" | "webp" | "avif"` (optional
|
|
143
|
-
-
|
|
139
|
+
- **`fmt`**: `"preserve" | "webp" | "avif"` (optional)
|
|
140
|
+
- If omitted, it defaults to `"preserve"`.
|
|
144
141
|
- **`w`**: `number` (optional)
|
|
145
142
|
- 32-bit integer
|
|
146
143
|
- **`h`**: `number` (optional)
|
|
147
144
|
- 32-bit integer
|
|
148
145
|
- **`fit`**: `"cover" | "contain" | "fill" | "inside" | "outside"` (optional)
|
|
149
146
|
- Only used when resizing (`w` and/or `h` is provided)
|
|
150
|
-
-
|
|
147
|
+
- If omitted, it defaults to `"inside"`.
|
|
151
148
|
- **`q`**: `number` (optional)
|
|
152
149
|
- Integer in `[0..100]`
|
|
153
|
-
- **Default
|
|
154
|
-
|
|
155
|
-
When building URLs, `fmt=preserve` is omitted from the query string (it’s treated as the “default”).
|
|
150
|
+
- **Default**: `100`
|
|
156
151
|
|
|
157
152
|
### License
|
|
158
153
|
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const createImageUrlBuilder: (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
fill: "fill";
|
|
11
|
-
inside: "inside";
|
|
12
|
-
outside: "outside";
|
|
13
|
-
}>>;
|
|
14
|
-
fmt: z.ZodEnum<{
|
|
15
|
-
preserve: "preserve";
|
|
16
|
-
webp: "webp";
|
|
17
|
-
avif: "avif";
|
|
18
|
-
}>;
|
|
19
|
-
q: z.ZodOptional<z.ZodInt32>;
|
|
20
|
-
source: z.ZodString;
|
|
21
|
-
}, z.core.$strip>>;
|
|
1
|
+
import { createImageUrlCodec } from "./createImageUrlCodec";
|
|
2
|
+
export declare const createImageUrlBuilder: (...args: Parameters<typeof createImageUrlCodec>) => (data: {
|
|
3
|
+
source: string;
|
|
4
|
+
w?: number | undefined;
|
|
5
|
+
h?: number | undefined;
|
|
6
|
+
fit?: "cover" | "contain" | "fill" | "inside" | "outside" | undefined;
|
|
7
|
+
fmt?: "preserve" | "webp" | "avif" | undefined;
|
|
8
|
+
q?: number | undefined;
|
|
9
|
+
}, params?: import("zod/v4/core").ParseContext<import("zod/v4/core").$ZodIssue>) => string;
|