next-image-transformer 0.3.0 → 1.0.0
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/{index-mUKn0C6P.js → createImageUrlCodec-Cpmqn0AP.js} +27 -27
- package/dist/createImageUrlCodec.d.ts +21 -0
- package/dist/index.js +2 -1
- package/dist/searchParamsToTransformConfigCodec.d.ts +2 -2
- package/dist/server.js +8 -8
- package/dist/transformConfigSchema.d.ts +2 -2
- package/package.json +1 -1
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;
|
|
@@ -128,7 +128,7 @@ function H(e, t, i) {
|
|
|
128
128
|
configurable: !0
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function G(...e) {
|
|
132
132
|
const t = {};
|
|
133
133
|
for (const i of e) {
|
|
134
134
|
const o = Object.getOwnPropertyDescriptors(i);
|
|
@@ -137,7 +137,7 @@ function V(...e) {
|
|
|
137
137
|
return Object.defineProperties({}, t);
|
|
138
138
|
}
|
|
139
139
|
function Sd(e) {
|
|
140
|
-
return
|
|
140
|
+
return G(e._zod.def);
|
|
141
141
|
}
|
|
142
142
|
function wd(e, t) {
|
|
143
143
|
return t ? t.reduce((i, o) => i?.[o], e) : e;
|
|
@@ -286,7 +286,7 @@ function ji(e, t) {
|
|
|
286
286
|
const i = e._zod.def, o = i.checks;
|
|
287
287
|
if (o && o.length > 0)
|
|
288
288
|
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
289
|
-
const r =
|
|
289
|
+
const r = G(e._zod.def, {
|
|
290
290
|
get shape() {
|
|
291
291
|
const a = {};
|
|
292
292
|
for (const c in t) {
|
|
@@ -304,7 +304,7 @@ function Ui(e, t) {
|
|
|
304
304
|
const i = e._zod.def, o = i.checks;
|
|
305
305
|
if (o && o.length > 0)
|
|
306
306
|
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
307
|
-
const r =
|
|
307
|
+
const r = G(e._zod.def, {
|
|
308
308
|
get shape() {
|
|
309
309
|
const a = { ...e._zod.def.shape };
|
|
310
310
|
for (const c in t) {
|
|
@@ -328,7 +328,7 @@ function Oi(e, t) {
|
|
|
328
328
|
if (Object.getOwnPropertyDescriptor(r, a) !== void 0)
|
|
329
329
|
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
330
330
|
}
|
|
331
|
-
const n =
|
|
331
|
+
const n = G(e._zod.def, {
|
|
332
332
|
get shape() {
|
|
333
333
|
const r = { ...e._zod.def.shape, ...t };
|
|
334
334
|
return H(this, "shape", r), r;
|
|
@@ -339,7 +339,7 @@ function Oi(e, t) {
|
|
|
339
339
|
function Di(e, t) {
|
|
340
340
|
if (!ne(t))
|
|
341
341
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
342
|
-
const i =
|
|
342
|
+
const i = G(e._zod.def, {
|
|
343
343
|
get shape() {
|
|
344
344
|
const o = { ...e._zod.def.shape, ...t };
|
|
345
345
|
return H(this, "shape", o), o;
|
|
@@ -348,7 +348,7 @@ function Di(e, t) {
|
|
|
348
348
|
return F(e, i);
|
|
349
349
|
}
|
|
350
350
|
function Ni(e, t) {
|
|
351
|
-
const i =
|
|
351
|
+
const i = G(e._zod.def, {
|
|
352
352
|
get shape() {
|
|
353
353
|
const o = { ...e._zod.def.shape, ...t._zod.def.shape };
|
|
354
354
|
return H(this, "shape", o), o;
|
|
@@ -365,7 +365,7 @@ function Pi(e, t, i) {
|
|
|
365
365
|
const n = t._zod.def.checks;
|
|
366
366
|
if (n && n.length > 0)
|
|
367
367
|
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
368
|
-
const a =
|
|
368
|
+
const a = G(t._zod.def, {
|
|
369
369
|
get shape() {
|
|
370
370
|
const c = t._zod.def.shape, l = { ...c };
|
|
371
371
|
if (i)
|
|
@@ -390,7 +390,7 @@ function Pi(e, t, i) {
|
|
|
390
390
|
return F(t, a);
|
|
391
391
|
}
|
|
392
392
|
function Zi(e, t, i) {
|
|
393
|
-
const o =
|
|
393
|
+
const o = G(t._zod.def, {
|
|
394
394
|
get shape() {
|
|
395
395
|
const n = t._zod.def.shape, r = { ...n };
|
|
396
396
|
if (i)
|
|
@@ -548,7 +548,7 @@ const Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
548
548
|
joinValues: p,
|
|
549
549
|
jsonStringifyReplacer: Qe,
|
|
550
550
|
merge: Ni,
|
|
551
|
-
mergeDefs:
|
|
551
|
+
mergeDefs: G,
|
|
552
552
|
normalizeParams: f,
|
|
553
553
|
nullish: ie,
|
|
554
554
|
numKeys: Ud,
|
|
@@ -8743,7 +8743,7 @@ const Ju = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
8743
8743
|
input: be(e, "input"),
|
|
8744
8744
|
output: be(e, "output")
|
|
8745
8745
|
}
|
|
8746
|
-
}), e.toJSONSchema = Hc(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...i) => e.clone(
|
|
8746
|
+
}), e.toJSONSchema = Hc(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...i) => e.clone(G(t, {
|
|
8747
8747
|
checks: [
|
|
8748
8748
|
...t.checks ?? [],
|
|
8749
8749
|
...i.map((o) => typeof o == "function" ? { _zod: { check: o, def: { check: "custom" }, onattach: [] } } : o)
|
|
@@ -8768,7 +8768,7 @@ const Ju = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
8768
8768
|
const i = e._zod.bag;
|
|
8769
8769
|
e.format = i.format ?? null, e.minLength = i.minimum ?? null, e.maxLength = i.maximum ?? null, e.regex = (...o) => e.check(/* @__PURE__ */ pn(...o)), e.includes = (...o) => e.check(/* @__PURE__ */ $n(...o)), e.startsWith = (...o) => e.check(/* @__PURE__ */ hn(...o)), e.endsWith = (...o) => e.check(/* @__PURE__ */ _n(...o)), e.min = (...o) => e.check(/* @__PURE__ */ te(...o)), e.max = (...o) => e.check(/* @__PURE__ */ Te(...o)), e.length = (...o) => e.check(/* @__PURE__ */ Ee(...o)), e.nonempty = (...o) => e.check(/* @__PURE__ */ te(1, ...o)), e.lowercase = (o) => e.check(/* @__PURE__ */ vn(o)), e.uppercase = (o) => e.check(/* @__PURE__ */ gn(o)), e.trim = () => e.check(/* @__PURE__ */ kn()), e.normalize = (...o) => e.check(/* @__PURE__ */ yn(...o)), e.toLowerCase = () => e.check(/* @__PURE__ */ zn()), e.toUpperCase = () => e.check(/* @__PURE__ */ In()), e.slugify = () => e.check(/* @__PURE__ */ Sn());
|
|
8770
8770
|
}), Le = /* @__PURE__ */ d("ZodString", (e, t) => {
|
|
8771
|
-
Pe.init(e, t), wn.init(e, t), e.email = (i) => e.check(/* @__PURE__ */ Nt(xn, i)), e.url = (i) => e.check(/* @__PURE__ */ fn(Re, i)), e.jwt = (i) => e.check(/* @__PURE__ */ Yt(Cn, i)), e.emoji = (i) => e.check(/* @__PURE__ */ At(jn, i)), e.guid = (i) => e.check(/* @__PURE__ */ tn(ye, i)), e.uuid = (i) => e.check(/* @__PURE__ */ Pt(
|
|
8771
|
+
Pe.init(e, t), wn.init(e, t), e.email = (i) => e.check(/* @__PURE__ */ Nt(xn, i)), e.url = (i) => e.check(/* @__PURE__ */ fn(Re, i)), e.jwt = (i) => e.check(/* @__PURE__ */ Yt(Cn, i)), e.emoji = (i) => e.check(/* @__PURE__ */ At(jn, i)), e.guid = (i) => e.check(/* @__PURE__ */ tn(ye, i)), e.uuid = (i) => e.check(/* @__PURE__ */ Pt(V, i)), e.uuidv4 = (i) => e.check(/* @__PURE__ */ Zt(V, i)), e.uuidv6 = (i) => e.check(/* @__PURE__ */ Tt(V, i)), e.uuidv7 = (i) => e.check(/* @__PURE__ */ Et(V, i)), e.nanoid = (i) => e.check(/* @__PURE__ */ Lt(Un, i)), e.guid = (i) => e.check(/* @__PURE__ */ tn(ye, i)), e.cuid = (i) => e.check(/* @__PURE__ */ Rt(On, i)), e.cuid2 = (i) => e.check(/* @__PURE__ */ Ft(Dn, i)), e.ulid = (i) => e.check(/* @__PURE__ */ Jt(Nn, i)), e.base64 = (i) => e.check(/* @__PURE__ */ Bt(Rn, i)), e.base64url = (i) => e.check(/* @__PURE__ */ qt(Fn, i)), e.xid = (i) => e.check(/* @__PURE__ */ Ct(Pn, i)), e.ksuid = (i) => e.check(/* @__PURE__ */ Mt(Zn, i)), e.ipv4 = (i) => e.check(/* @__PURE__ */ Kt(Tn, i)), e.ipv6 = (i) => e.check(/* @__PURE__ */ Vt(En, i)), e.cidrv4 = (i) => e.check(/* @__PURE__ */ Gt(An, i)), e.cidrv6 = (i) => e.check(/* @__PURE__ */ Wt(Ln, i)), e.e164 = (i) => e.check(/* @__PURE__ */ Xt(Jn, i)), e.datetime = (i) => e.check(Au(i)), e.date = (i) => e.check(Lu(i)), e.time = (i) => e.check(Ru(i)), e.duration = (i) => e.check(Fu(i));
|
|
8772
8772
|
});
|
|
8773
8773
|
function rn(e) {
|
|
8774
8774
|
return /* @__PURE__ */ mc(Le, e);
|
|
@@ -8787,20 +8787,20 @@ const ye = /* @__PURE__ */ d("ZodGUID", (e, t) => {
|
|
|
8787
8787
|
function tl(e) {
|
|
8788
8788
|
return /* @__PURE__ */ tn(ye, e);
|
|
8789
8789
|
}
|
|
8790
|
-
const
|
|
8790
|
+
const V = /* @__PURE__ */ d("ZodUUID", (e, t) => {
|
|
8791
8791
|
Wo.init(e, t), w.init(e, t);
|
|
8792
8792
|
});
|
|
8793
8793
|
function rl(e) {
|
|
8794
|
-
return /* @__PURE__ */ Pt(
|
|
8794
|
+
return /* @__PURE__ */ Pt(V, e);
|
|
8795
8795
|
}
|
|
8796
8796
|
function il(e) {
|
|
8797
|
-
return /* @__PURE__ */ Zt(
|
|
8797
|
+
return /* @__PURE__ */ Zt(V, e);
|
|
8798
8798
|
}
|
|
8799
8799
|
function ol(e) {
|
|
8800
|
-
return /* @__PURE__ */ Tt(
|
|
8800
|
+
return /* @__PURE__ */ Tt(V, e);
|
|
8801
8801
|
}
|
|
8802
8802
|
function al(e) {
|
|
8803
|
-
return /* @__PURE__ */ Et(
|
|
8803
|
+
return /* @__PURE__ */ Et(V, e);
|
|
8804
8804
|
}
|
|
8805
8805
|
const Re = /* @__PURE__ */ d("ZodURL", (e, t) => {
|
|
8806
8806
|
qo.init(e, t), w.init(e, t);
|
|
@@ -9534,7 +9534,7 @@ const Df = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
9534
9534
|
ZodType: y,
|
|
9535
9535
|
ZodULID: Nn,
|
|
9536
9536
|
ZodURL: Re,
|
|
9537
|
-
ZodUUID:
|
|
9537
|
+
ZodUUID: V,
|
|
9538
9538
|
ZodUndefined: fr,
|
|
9539
9539
|
ZodUnion: Ve,
|
|
9540
9540
|
ZodUnknown: $r,
|
|
@@ -10041,7 +10041,7 @@ const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10041
10041
|
ZodType: y,
|
|
10042
10042
|
ZodULID: Nn,
|
|
10043
10043
|
ZodURL: Re,
|
|
10044
|
-
ZodUUID:
|
|
10044
|
+
ZodUUID: V,
|
|
10045
10045
|
ZodUndefined: fr,
|
|
10046
10046
|
ZodUnion: Ve,
|
|
10047
10047
|
ZodUnknown: $r,
|
|
@@ -10212,10 +10212,10 @@ const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10212
10212
|
* Defaults to `"inside"` when omitted.
|
|
10213
10213
|
*/
|
|
10214
10214
|
fit: U.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
|
|
10215
|
-
fmt: U.enum(["preserve", "webp", "avif"]),
|
|
10215
|
+
fmt: U.enum(["preserve", "webp", "avif"]).optional(),
|
|
10216
10216
|
q: U.int32().min(0).max(100).optional(),
|
|
10217
10217
|
source: U.string()
|
|
10218
|
-
}),
|
|
10218
|
+
}), K = (e) => e != null, Qn = U.codec(
|
|
10219
10219
|
U.string().regex(U.regexes.integer),
|
|
10220
10220
|
U.int(),
|
|
10221
10221
|
{
|
|
@@ -10228,14 +10228,14 @@ const U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10228
10228
|
{
|
|
10229
10229
|
encode: (e) => {
|
|
10230
10230
|
const t = new URLSearchParams();
|
|
10231
|
-
return
|
|
10231
|
+
return K(e.w) && t.set("w", String(e.w)), K(e.h) && t.set("h", String(e.h)), K(e.fit) && t.set("fit", e.fit), K(e.fmt) && t.set("fmt", e.fmt), K(e.q) && t.set("q", String(e.q)), t.set("source", e.source), t;
|
|
10232
10232
|
},
|
|
10233
10233
|
decode: (e) => ({
|
|
10234
|
-
w:
|
|
10235
|
-
h:
|
|
10236
|
-
fit:
|
|
10237
|
-
fmt:
|
|
10238
|
-
q:
|
|
10234
|
+
w: K(e.get("w")) ? Qn.decode(e.get("w") ?? "") : void 0,
|
|
10235
|
+
h: K(e.get("h")) ? Qn.decode(e.get("h") ?? "") : void 0,
|
|
10236
|
+
fit: K(e.get("fit")) ? U.enum(["cover", "contain", "fill", "inside", "outside"]).parse(e.get("fit")) : void 0,
|
|
10237
|
+
fmt: K(e.get("fmt")) ? U.enum(["preserve", "webp", "avif"]).parse(e.get("fmt")) : void 0,
|
|
10238
|
+
q: K(e.get("q")) ? Qn.decode(e.get("q") ?? "") : void 0,
|
|
10239
10239
|
source: U.string().parse(e.get("source"))
|
|
10240
10240
|
})
|
|
10241
10241
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare const createImageUrlCodec: ({ 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.ZodOptional<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>>;
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,11 @@ export declare const searchParamsToTransformConfigCodec: z.ZodCodec<z.ZodCustom<
|
|
|
9
9
|
inside: "inside";
|
|
10
10
|
outside: "outside";
|
|
11
11
|
}>>;
|
|
12
|
-
fmt: z.ZodEnum<{
|
|
12
|
+
fmt: z.ZodOptional<z.ZodEnum<{
|
|
13
13
|
preserve: "preserve";
|
|
14
14
|
webp: "webp";
|
|
15
15
|
avif: "avif";
|
|
16
|
-
}
|
|
16
|
+
}>>;
|
|
17
17
|
q: z.ZodOptional<z.ZodInt32>;
|
|
18
18
|
source: z.ZodString;
|
|
19
19
|
}, z.core.$strip>>;
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import h from "node:path";
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as T, c as B } from "./createImageUrlCodec-Cpmqn0AP.js";
|
|
3
3
|
import { createHash as U } from "node:crypto";
|
|
4
4
|
import m from "node:fs/promises";
|
|
5
5
|
import b from "sharp";
|
|
@@ -30,8 +30,8 @@ async function q({
|
|
|
30
30
|
m.readFile(a, "utf8")
|
|
31
31
|
]), o = (() => {
|
|
32
32
|
try {
|
|
33
|
-
const i = JSON.parse(u), e =
|
|
34
|
-
contentType:
|
|
33
|
+
const i = JSON.parse(u), e = T.object({
|
|
34
|
+
contentType: T.string()
|
|
35
35
|
}).loose().safeParse(i);
|
|
36
36
|
return e.success ? e.data : null;
|
|
37
37
|
} catch {
|
|
@@ -170,24 +170,24 @@ const O = ({
|
|
|
170
170
|
throw new Error(`Unreachable case: ${e.fmt}`);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
).toBuffer(), $ = new Uint8Array(R),
|
|
173
|
+
).toBuffer(), $ = new Uint8Array(R), C = (() => {
|
|
174
174
|
switch (e.fmt) {
|
|
175
|
-
case "preserve":
|
|
176
|
-
return w.headers.get("content-type") ?? "application/octet-stream";
|
|
177
175
|
case "avif":
|
|
178
176
|
return "image/avif";
|
|
179
177
|
case "webp":
|
|
180
178
|
return "image/webp";
|
|
179
|
+
default:
|
|
180
|
+
return w.headers.get("content-type") ?? "application/octet-stream";
|
|
181
181
|
}
|
|
182
182
|
})();
|
|
183
183
|
return await A({
|
|
184
184
|
cacheKey: g,
|
|
185
185
|
body: R,
|
|
186
|
-
meta: { contentType:
|
|
186
|
+
meta: { contentType: C },
|
|
187
187
|
cacheDir: n
|
|
188
188
|
}), new Response($, {
|
|
189
189
|
headers: {
|
|
190
|
-
"Content-Type":
|
|
190
|
+
"Content-Type": C,
|
|
191
191
|
"Cache-Control": s
|
|
192
192
|
}
|
|
193
193
|
});
|
|
@@ -9,11 +9,11 @@ export declare const transformConfigSchema: z.ZodObject<{
|
|
|
9
9
|
inside: "inside";
|
|
10
10
|
outside: "outside";
|
|
11
11
|
}>>;
|
|
12
|
-
fmt: z.ZodEnum<{
|
|
12
|
+
fmt: z.ZodOptional<z.ZodEnum<{
|
|
13
13
|
preserve: "preserve";
|
|
14
14
|
webp: "webp";
|
|
15
15
|
avif: "avif";
|
|
16
|
-
}
|
|
16
|
+
}>>;
|
|
17
17
|
q: z.ZodOptional<z.ZodInt32>;
|
|
18
18
|
source: z.ZodString;
|
|
19
19
|
}, z.core.$strip>;
|