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 CHANGED
@@ -71,7 +71,7 @@ import { imageUrlBuilder } from "../lib/imageUrlBuilder";
71
71
  export function MyImage() {
72
72
  return (
73
73
  <img
74
- src={imageUrlBuilder.encode({
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 Zod codec that can:
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 in the URL)
143
- - **Default (when decoding)**: `"preserve"`
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
- - **Default (when decoding)**: `"inside"`
147
+ - If omitted, it defaults to `"inside"`.
151
148
  - **`q`**: `number` (optional)
152
149
  - Integer in `[0..100]`
153
- - **Default (when transforming)**: `100`
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 z from "zod";
2
- export declare const createImageUrlBuilder: ({ apiRouteUrl, }: {
3
- apiRouteUrl: string;
4
- }) => z.ZodCodec<z.ZodURL, z.ZodObject<{
5
- w: z.ZodOptional<z.ZodInt32>;
6
- h: z.ZodOptional<z.ZodInt32>;
7
- fit: z.ZodOptional<z.ZodEnum<{
8
- cover: "cover";
9
- contain: "contain";
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;