ipx 4.0.0-alpha.1 → 4.0.0-alpha.2

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.
@@ -1 +1,41 @@
1
- String.fromCharCode;function decode(e=``){try{return decodeURIComponent(``+e)}catch{return``+e}}const PROTOCOL_STRICT_REGEX=/^[\s\w\0+.-]{2,}:([/\\]{1,2})/,PROTOCOL_REGEX=/^[\s\w\0+.-]{2,}:([/\\]{2})?/,PROTOCOL_RELATIVE_REGEX=/^([/\\]\s*){2,}[^/\\]/,TRAILING_SLASH_RE=/\/$|\/\?|\/#/,JOIN_LEADING_SLASH_RE=/^\.?\//;function hasProtocol(e,u={}){return typeof u==`boolean`&&(u={acceptRelative:u}),u.strict?PROTOCOL_STRICT_REGEX.test(e):PROTOCOL_REGEX.test(e)||(u.acceptRelative?PROTOCOL_RELATIVE_REGEX.test(e):!1)}function hasTrailingSlash(e=``,s){return s?TRAILING_SLASH_RE.test(e):e.endsWith(`/`)}function withTrailingSlash(e=``,s){if(!s)return e.endsWith(`/`)?e:e+`/`;if(hasTrailingSlash(e,!0))return e||`/`;let c=e,l=``,u=e.indexOf(`#`);if(u!==-1&&(c=e.slice(0,u),l=e.slice(u),!c))return l;let[d,...f]=c.split(`?`);return d+`/`+(f.length>0?`?${f.join(`?`)}`:``)+l}function hasLeadingSlash(e=``){return e.startsWith(`/`)}function withLeadingSlash(e=``){return hasLeadingSlash(e)?e:`/`+e}function isNonEmptyURL(e){return e&&e!==`/`}function joinURL(e,...s){let c=e||``;for(let e of s.filter(e=>isNonEmptyURL(e)))if(c){let s=e.replace(JOIN_LEADING_SLASH_RE,``);c=withTrailingSlash(c)+s}else c=e;return c}export{withLeadingSlash as i,hasProtocol as n,joinURL as r,decode as t};
1
+ String.fromCharCode;
2
+ function e(e = ``) {
3
+ try {
4
+ return decodeURIComponent(`` + e);
5
+ } catch {
6
+ return `` + e;
7
+ }
8
+ }
9
+ const t = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/, n = /^[\s\w\0+.-]{2,}:([/\\]{2})?/, r = /^([/\\]\s*){2,}[^/\\]/, i = /\/$|\/\?|\/#/, a = /^\.?\//;
10
+ function o(e, i = {}) {
11
+ return typeof i == `boolean` && (i = { acceptRelative: i }), i.strict ? t.test(e) : n.test(e) || (i.acceptRelative ? r.test(e) : !1);
12
+ }
13
+ function s(e = ``, t) {
14
+ return t ? i.test(e) : e.endsWith(`/`);
15
+ }
16
+ function c(e = ``, t) {
17
+ if (!t) return e.endsWith(`/`) ? e : e + `/`;
18
+ if (s(e, !0)) return e || `/`;
19
+ let n = e, r = ``, i = e.indexOf(`#`);
20
+ if (i !== -1 && (n = e.slice(0, i), r = e.slice(i), !n)) return r;
21
+ let [a, ...o] = n.split(`?`);
22
+ return a + `/` + (o.length > 0 ? `?${o.join(`?`)}` : ``) + r;
23
+ }
24
+ function l(e = ``) {
25
+ return e.startsWith(`/`);
26
+ }
27
+ function u(e = ``) {
28
+ return l(e) ? e : `/` + e;
29
+ }
30
+ function d(e) {
31
+ return e && e !== `/`;
32
+ }
33
+ function f(e, ...t) {
34
+ let n = e || ``;
35
+ for (let e of t.filter((e) => d(e))) if (n) {
36
+ let t = e.replace(a, ``);
37
+ n = c(n) + t;
38
+ } else n = e;
39
+ return n;
40
+ }
41
+ export { e as decode, o as hasProtocol, f as joinURL, u as withLeadingSlash };
@@ -1,19 +1,19 @@
1
- import { a as __toESM, i as __toDynamicImportESM, n as __export } from "./rolldown-runtime.mjs";
2
- import { i as withLeadingSlash, n as hasProtocol, r as joinURL, t as decode } from "./libs/ufo.mjs";
3
- import { n as defineEventHandler, t as HTTPError } from "./libs/h3.mjs";
4
- import { t as imageMeta } from "./libs/image-meta.mjs";
5
- import { t as require_etag } from "./libs/etag.mjs";
6
- import { t as require_accept_negotiator } from "./libs/@fastify/accept-negotiator.mjs";
1
+ import { __exportAll, __toESM } from "./rolldown-runtime.mjs";
2
+ import { decode, hasProtocol, joinURL, withLeadingSlash } from "./libs/ufo.mjs";
3
+ import { HTTPError, defineEventHandler } from "./libs/h3.mjs";
4
+ import { imageMeta } from "./libs/image-meta.mjs";
5
+ import { require_etag } from "./libs/etag.mjs";
6
+ import { require_accept_negotiator } from "./libs/@fastify/accept-negotiator.mjs";
7
7
  import { join, parse, resolve } from "pathe";
8
-
9
- //#region src/handlers/utils.ts
10
8
  function VArg(argument) {
11
9
  if (argument === "Infinity") return Infinity;
10
+ if (argument === "undefined") return;
12
11
  try {
13
12
  const val = JSON.parse(argument);
14
13
  const t = typeof val;
15
14
  if (t === "boolean" || t === "number" || t === "string" || val === null) return val;
16
15
  } catch {}
16
+ return argument;
17
17
  }
18
18
  function parseArgs(arguments_, mappers) {
19
19
  const vargs = arguments_.split("_");
@@ -28,24 +28,21 @@ function applyHandler(context, pipe, handler, argumentsString) {
28
28
  }
29
29
  function clampDimensionsPreservingAspectRatio(sourceDimensions, desiredDimensions) {
30
30
  const desiredAspectRatio = desiredDimensions.width / desiredDimensions.height;
31
- let { width: width$1, height: height$1 } = desiredDimensions;
32
- if (sourceDimensions.width && width$1 > sourceDimensions.width) {
33
- width$1 = sourceDimensions.width;
34
- height$1 = Math.round(sourceDimensions.width / desiredAspectRatio);
31
+ let { width, height } = desiredDimensions;
32
+ if (sourceDimensions.width && width > sourceDimensions.width) {
33
+ width = sourceDimensions.width;
34
+ height = Math.round(sourceDimensions.width / desiredAspectRatio);
35
35
  }
36
- if (sourceDimensions.height && height$1 > sourceDimensions.height) {
37
- height$1 = sourceDimensions.height;
38
- width$1 = Math.round(sourceDimensions.height * desiredAspectRatio);
36
+ if (sourceDimensions.height && height > sourceDimensions.height) {
37
+ height = sourceDimensions.height;
38
+ width = Math.round(sourceDimensions.height * desiredAspectRatio);
39
39
  }
40
40
  return {
41
- width: width$1,
42
- height: height$1
41
+ width,
42
+ height
43
43
  };
44
44
  }
45
-
46
- //#endregion
47
- //#region src/handlers/handlers.ts
48
- var handlers_exports = /* @__PURE__ */ __export({
45
+ var handlers_exports = /* @__PURE__ */ __exportAll({
49
46
  b: () => b,
50
47
  background: () => background,
51
48
  blur: () => blur,
@@ -83,22 +80,22 @@ var handlers_exports = /* @__PURE__ */ __export({
83
80
  const quality = {
84
81
  args: [VArg],
85
82
  order: -1,
86
- apply: (context, _pipe, quality$1) => {
87
- context.quality = quality$1;
83
+ apply: (context, _pipe, quality) => {
84
+ context.quality = quality;
88
85
  }
89
86
  };
90
87
  const fit = {
91
88
  args: [VArg],
92
89
  order: -1,
93
- apply: (context, _pipe, fit$1) => {
94
- context.fit = fit$1;
90
+ apply: (context, _pipe, fit) => {
91
+ context.fit = fit;
95
92
  }
96
93
  };
97
94
  const position = {
98
95
  args: [VArg],
99
96
  order: -1,
100
- apply: (context, _pipe, position$1) => {
101
- context.position = position$1;
97
+ apply: (context, _pipe, position) => {
98
+ context.position = position;
102
99
  }
103
100
  };
104
101
  const HEX_RE = /^([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;
@@ -106,10 +103,10 @@ const SHORTHEX_RE = /^([\da-f])([\da-f])([\da-f])$/i;
106
103
  const background = {
107
104
  args: [VArg],
108
105
  order: -1,
109
- apply: (context, _pipe, background$1) => {
110
- background$1 = String(background$1);
111
- if (!background$1.startsWith("#") && (HEX_RE.test(background$1) || SHORTHEX_RE.test(background$1))) background$1 = "#" + background$1;
112
- context.background = background$1;
106
+ apply: (context, _pipe, background) => {
107
+ background = String(background);
108
+ if (!background.startsWith("#") && (HEX_RE.test(background) || SHORTHEX_RE.test(background))) background = "#" + background;
109
+ context.background = background;
113
110
  }
114
111
  };
115
112
  const enlarge = {
@@ -120,20 +117,20 @@ const enlarge = {
120
117
  };
121
118
  const kernel = {
122
119
  args: [VArg],
123
- apply: (context, _pipe, kernel$1) => {
124
- context.kernel = kernel$1;
120
+ apply: (context, _pipe, kernel) => {
121
+ context.kernel = kernel;
125
122
  }
126
123
  };
127
124
  const width = {
128
125
  args: [VArg],
129
- apply: (context, pipe, width$1) => {
130
- return pipe.resize(width$1, void 0, { withoutEnlargement: !context.enlarge });
126
+ apply: (context, pipe, width) => {
127
+ return pipe.resize(width, void 0, { withoutEnlargement: !context.enlarge });
131
128
  }
132
129
  };
133
130
  const height = {
134
131
  args: [VArg],
135
- apply: (context, pipe, height$1) => {
136
- return pipe.resize(void 0, height$1, { withoutEnlargement: !context.enlarge });
132
+ apply: (context, pipe, height) => {
133
+ return pipe.resize(void 0, height, { withoutEnlargement: !context.enlarge });
137
134
  }
138
135
  };
139
136
  const resize = {
@@ -143,18 +140,18 @@ const resize = {
143
140
  VArg
144
141
  ],
145
142
  apply: (context, pipe, size) => {
146
- let [width$1, height$1] = String(size).split("x").map(Number);
147
- if (!width$1) return;
148
- if (!height$1) height$1 = width$1;
143
+ let [width, height] = String(size).split("x").map(Number);
144
+ if (!width) return;
145
+ if (!height) height = width;
149
146
  if (!context.enlarge) {
150
147
  const clamped = clampDimensionsPreservingAspectRatio(context.meta, {
151
- width: width$1,
152
- height: height$1
148
+ width,
149
+ height
153
150
  });
154
- width$1 = clamped.width;
155
- height$1 = clamped.height;
151
+ width = clamped.width;
152
+ height = clamped.height;
156
153
  }
157
- return pipe.resize(width$1, height$1, {
154
+ return pipe.resize(width, height, {
158
155
  fit: context.fit,
159
156
  position: context.position,
160
157
  background: context.background,
@@ -164,8 +161,8 @@ const resize = {
164
161
  };
165
162
  const trim = {
166
163
  args: [VArg],
167
- apply: (_context, pipe, threshold$1) => {
168
- return pipe.trim(threshold$1);
164
+ apply: (_context, pipe, threshold) => {
165
+ return pipe.trim(threshold);
169
166
  }
170
167
  };
171
168
  const extend = {
@@ -192,12 +189,12 @@ const extract = {
192
189
  VArg,
193
190
  VArg
194
191
  ],
195
- apply: (_context, pipe, left, top, width$1, height$1) => {
192
+ apply: (_context, pipe, left, top, width, height) => {
196
193
  return pipe.extract({
197
194
  left,
198
195
  top,
199
- width: width$1,
200
- height: height$1
196
+ width,
197
+ height
201
198
  });
202
199
  }
203
200
  };
@@ -226,7 +223,11 @@ const sharpen = {
226
223
  VArg
227
224
  ],
228
225
  apply: (_context, pipe, sigma, flat, jagged) => {
229
- return pipe.sharpen(sigma, flat, jagged);
226
+ return pipe.sharpen({
227
+ sigma,
228
+ m1: flat,
229
+ m2: jagged
230
+ });
230
231
  }
231
232
  };
232
233
  const median = {
@@ -265,8 +266,8 @@ const gamma = {
265
266
  VArg,
266
267
  VArg
267
268
  ],
268
- apply: (_context, pipe, gamma$1, gammaOut) => {
269
- return pipe.gamma(gamma$1, gammaOut);
269
+ apply: (_context, pipe, gamma, gammaOut) => {
270
+ return pipe.gamma(gamma, gammaOut);
270
271
  }
271
272
  };
272
273
  const negate = {
@@ -291,8 +292,8 @@ const normalize = {
291
292
  };
292
293
  const threshold = {
293
294
  args: [VArg],
294
- apply: (_context, pipe, threshold$1) => {
295
- return pipe.threshold(threshold$1);
295
+ apply: (_context, pipe, threshold) => {
296
+ return pipe.threshold(threshold);
296
297
  }
297
298
  };
298
299
  const modulate = {
@@ -324,9 +325,6 @@ const w = width;
324
325
  const h = height;
325
326
  const s = resize;
326
327
  const pos = position;
327
-
328
- //#endregion
329
- //#region src/utils.ts
330
328
  function getEnv(name) {
331
329
  const value = globalThis.process?.env?.[name];
332
330
  if (value !== void 0) return JSON.parse(value);
@@ -343,10 +341,7 @@ function cachedPromise(function_) {
343
341
  return p;
344
342
  };
345
343
  }
346
-
347
- //#endregion
348
- //#region src/ipx.ts
349
- const SUPPORTED_FORMATS = new Set([
344
+ const SUPPORTED_FORMATS = /* @__PURE__ */ new Set([
350
345
  "jpeg",
351
346
  "png",
352
347
  "webp",
@@ -356,12 +351,6 @@ const SUPPORTED_FORMATS = new Set([
356
351
  "gif",
357
352
  "heic"
358
353
  ]);
359
- /**
360
- * Creates an IPX image processing instance with the specified options.
361
- * @param {IPXOptions} userOptions - Configuration options for the IPX instance. See {@link IPXOptions}.
362
- * @returns {IPX} An IPX processing function configured with the given options. See {@link IPX}.
363
- * @throws {Error} If critical options such as storage are missing or incorrectly configured.
364
- */
365
354
  function createIPX(userOptions) {
366
355
  const options = {
367
356
  ...userOptions,
@@ -377,7 +366,7 @@ function createIPX(userOptions) {
377
366
  return await import("sharp").then((r) => r.default || r);
378
367
  });
379
368
  const getSVGO = cachedPromise(async () => {
380
- const { optimize } = await import("./svgo-node.mjs").then(__toDynamicImportESM(1));
369
+ const { optimize } = await import("./svgo-node.mjs").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
381
370
  return { optimize };
382
371
  });
383
372
  return function ipx(id, modifiers = {}, opts = {}) {
@@ -459,13 +448,13 @@ function createIPX(userOptions) {
459
448
  handler: getHandler(name),
460
449
  name,
461
450
  args: arguments_
462
- })).filter((h$1) => h$1.handler).sort((a, b$1) => {
451
+ })).filter((h) => h.handler).sort((a, b) => {
463
452
  const aKey = (a.handler.order || a.name || "").toString();
464
- const bKey = (b$1.handler.order || b$1.name || "").toString();
453
+ const bKey = (b.handler.order || b.name || "").toString();
465
454
  return aKey.localeCompare(bKey);
466
455
  });
467
456
  const handlerContext = { meta: imageMeta$1 };
468
- for (const h$1 of handlers) sharp = applyHandler(handlerContext, sharp, h$1.handler, h$1.args.toString()) || sharp;
457
+ for (const h of handlers) sharp = applyHandler(handlerContext, sharp, h.handler, h.args.toString()) || sharp;
469
458
  if (SUPPORTED_FORMATS.has(format || "")) sharp = sharp.toFormat(format, { quality: handlerContext.quality });
470
459
  return {
471
460
  data: await sharp.toBuffer(),
@@ -476,9 +465,6 @@ function createIPX(userOptions) {
476
465
  };
477
466
  };
478
467
  }
479
-
480
- //#endregion
481
- //#region src/server.ts
482
468
  var import_etag = /* @__PURE__ */ __toESM(require_etag(), 1);
483
469
  var import_accept_negotiator = require_accept_negotiator();
484
470
  function createIPXFetchHandler(ipx) {
@@ -490,10 +476,10 @@ function createIPXNodeHandler(ipx) {
490
476
  }
491
477
  function serveIPX(ipx, opts) {
492
478
  const { serve } = requireModule("srvx");
493
- const fetch$1 = createIPXFetchHandler(ipx);
479
+ const fetch = createIPXFetchHandler(ipx);
494
480
  return serve({
495
481
  ...opts,
496
- fetch: fetch$1
482
+ fetch
497
483
  });
498
484
  }
499
485
  const MODIFIER_SEP = /[&,]/g;
@@ -569,24 +555,13 @@ function autoDetectFormat(acceptHeader, animated) {
569
555
  function safeString(input) {
570
556
  return JSON.stringify(input).replace(/^"|"$/g, "").replace(/\\+/g, "\\").replace(/\\"/g, "\"");
571
557
  }
572
-
573
- //#endregion
574
- //#region src/storage/http.ts
575
558
  const HTTP_RE = /^https?:\/\//;
576
- /**
577
- * Creates an HTTP storage handler for IPX that fetches image data from external URLs.
578
- * This handler allows configuration to specify allowed domains, caching behaviour and custom fetch options.
579
- *
580
- * @param {HTTPStorageOptions} [_options={}] - Configuration options for HTTP storage, with defaults possibly taken from environment variables. See {@link HTTPStorageOptions}.
581
- * @returns {IPXStorage} An IPXStorage interface implementation for retrieving images over HTTP. See {@link IPXStorage}.
582
- * @throws {H3Error} If validation of the requested URL fails due to a missing hostname or denied host access. See {@link H3Error}.
583
- */
584
559
  function ipxHttpStorage(_options = {}) {
585
560
  const allowAllDomains = _options.allowAllDomains ?? getEnv("IPX_HTTP_ALLOW_ALL_DOMAINS") ?? false;
586
561
  let _domains = _options.domains || getEnv("IPX_HTTP_DOMAINS") || [];
587
562
  const defaultMaxAge = _options.maxAge || getEnv("IPX_HTTP_MAX_AGE") || 300;
588
563
  const fetchOptions = _options.fetchOptions || getEnv("IPX_HTTP_FETCH_OPTIONS") || {};
589
- if (typeof _domains === "string") _domains = _domains.split(",").map((s$1) => s$1.trim());
564
+ if (typeof _domains === "string") _domains = _domains.split(",").map((s) => s.trim());
590
565
  const domains = new Set(_domains.map((d) => {
591
566
  if (!HTTP_RE.test(d)) d = "http://" + d;
592
567
  return new URL(d).hostname;
@@ -653,17 +628,6 @@ function ipxHttpStorage(_options = {}) {
653
628
  }
654
629
  };
655
630
  }
656
-
657
- //#endregion
658
- //#region src/storage/node-fs.ts
659
- /**
660
- * Creates a file system storage handler for IPX that allows images to be served from local directories specified in the options.
661
- * This handler resolves directories and handles file access, ensuring that files are served safely.
662
- *
663
- * @param {NodeFSSOptions} [_options={}] - File system storage configuration options, with optional directory paths and caching configuration. See {@link NodeFSSOptions}.
664
- * @returns {IPXStorage} An implementation of the IPXStorage interface for accessing images stored on the local file system. See {@link IPXStorage}.
665
- * @throws {H3Error} If there is a problem accessing the file system module or resolving/reading files. See {@link H3Error}.
666
- */
667
631
  function ipxFSStorage(_options = {}) {
668
632
  const dirs = resolveDirs(_options.dir);
669
633
  const maxAge = _options.maxAge || getEnv("IPX_FS_MAX_AGE");
@@ -721,8 +685,6 @@ function isValidPath(fp) {
721
685
  }
722
686
  function resolveDirs(dirs) {
723
687
  if (!dirs || !Array.isArray(dirs)) return [resolve(dirs || getEnv("IPX_FS_DIR") || ".")];
724
- return dirs.map((dirs$1) => resolve(dirs$1));
688
+ return dirs.map((dirs) => resolve(dirs));
725
689
  }
726
-
727
- //#endregion
728
- export { serveIPX as a, createIPXNodeHandler as i, ipxHttpStorage as n, createIPX as o, createIPXFetchHandler as r, ipxFSStorage as t };
690
+ export { createIPX, createIPXFetchHandler, createIPXNodeHandler, ipxFSStorage, ipxHttpStorage, serveIPX };
@@ -1,37 +1,35 @@
1
1
  import { createRequire } from "node:module";
2
-
3
- //#region rolldown:runtime
4
2
  var __create = Object.create;
5
3
  var __defProp = Object.defineProperty;
6
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
6
  var __getProtoOf = Object.getPrototypeOf;
9
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
11
- var __export = (all, symbols) => {
12
- let target = {};
13
- for (var name in all) {
14
- __defProp(target, name, {
15
- get: all[name],
16
- enumerable: true
17
- });
18
- }
19
- if (symbols) {
20
- __defProp(target, Symbol.toStringTag, { value: "Module" });
8
+ var __esmMin = (fn, res, err) => () => {
9
+ if (err) throw err[0];
10
+ try {
11
+ return fn && (res = fn(fn = 0)), res;
12
+ } catch (e) {
13
+ throw err = [e], e;
21
14
  }
15
+ };
16
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
17
+ var __exportAll = (all, no_symbols) => {
18
+ let target = {};
19
+ for (var name in all) __defProp(target, name, {
20
+ get: all[name],
21
+ enumerable: true
22
+ });
23
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
22
24
  return target;
23
25
  };
24
26
  var __copyProps = (to, from, except, desc) => {
25
- if (from && typeof from === "object" || typeof from === "function") {
26
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
27
- key = keys[i];
28
- if (!__hasOwnProp.call(to, key) && key !== except) {
29
- __defProp(to, key, {
30
- get: ((k) => from[k]).bind(null, key),
31
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
32
- });
33
- }
34
- }
27
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
28
+ key = keys[i];
29
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
30
+ get: ((k) => from[k]).bind(null, key),
31
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
32
+ });
35
33
  }
36
34
  return to;
37
35
  };
@@ -39,8 +37,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
37
  value: mod,
40
38
  enumerable: true
41
39
  }) : target, mod));
42
- var __toDynamicImportESM = (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode);
43
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
44
-
45
- //#endregion
46
- export { __toESM as a, __toDynamicImportESM as i, __export as n, __require as r, __commonJSMin as t };
40
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
42
+ export { __commonJSMin, __esmMin, __exportAll, __require, __toCommonJS, __toESM };
@@ -1,11 +1,3 @@
1
- import "./rolldown-runtime.mjs";
2
- import "./libs/css-select.mjs";
3
- import "./libs/boolbase.mjs";
4
- import "./libs/css-tree.mjs";
5
- import "./libs/csso.mjs";
6
- import "./libs/sax.mjs";
7
- import { t as require_svgo_node } from "./libs/svgo.mjs";
8
-
1
+ import { require_svgo_node } from "./libs/svgo.mjs";
9
2
  export default require_svgo_node();
10
-
11
- export { };
3
+ export {};
package/dist/cli.mjs CHANGED
@@ -1,16 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import "./_chunks/rolldown-runtime.mjs";
3
- import { a as serveIPX, n as ipxHttpStorage, o as createIPX, t as ipxFSStorage } from "./_chunks/node-fs.mjs";
4
- import "./_chunks/libs/etag.mjs";
5
- import "./_chunks/libs/@fastify/accept-negotiator.mjs";
2
+ import { createIPX, ipxFSStorage, ipxHttpStorage, serveIPX } from "./_chunks/node-fs.mjs";
6
3
  import { parseArgs } from "node:util";
7
-
8
- //#region package.json
9
4
  var name = "ipx";
10
- var version = "4.0.0-alpha.0";
11
-
12
- //#endregion
13
- //#region src/cli.ts
5
+ var version = "4.0.0-alpha.1";
14
6
  const { positionals, values } = parseArgs({
15
7
  allowPositionals: true,
16
8
  options: {
@@ -74,6 +66,4 @@ Options:
74
66
  -v, --version Show version
75
67
  `);
76
68
  }
77
-
78
- //#endregion
79
- export { };
69
+ export {};
package/dist/index.d.mts CHANGED
@@ -1,10 +1,8 @@
1
+ import { ImageMeta } from "./_chunks/libs/image-meta.mjs";
1
2
  import { NodeHttpHandler, Server, ServerOptions } from "srvx";
2
3
  import { Color, KernelEnum, Sharp, SharpOptions } from "sharp";
3
- import { ImageMeta } from "image-meta";
4
4
  import { Config } from "svgo";
5
5
  import { Driver, Storage } from "unstorage";
6
-
7
- //#region src/types.d.ts
8
6
  interface HandlerContext {
9
7
  /**
10
8
  * Optional quality setting for the output image, affects compression in certain formats.
@@ -96,8 +94,6 @@ interface IPXStorage {
96
94
  */
97
95
  getData: (id: string, opts?: IPXStorageOptions) => MaybePromise<Buffer | ArrayBuffer | undefined>;
98
96
  }
99
- //#endregion
100
- //#region src/ipx.d.ts
101
97
  type IPXSourceMeta = {
102
98
  /**
103
99
  * The modification time of the source. Used for cache validation.
@@ -213,14 +209,10 @@ type IPXOptions = {
213
209
  * @throws {Error} If critical options such as storage are missing or incorrectly configured.
214
210
  */
215
211
  declare function createIPX(userOptions: IPXOptions): IPX;
216
- //#endregion
217
- //#region src/server.d.ts
218
212
  type FetchHandler = (request: Request | string | URL) => Response | Promise<Response>;
219
213
  declare function createIPXFetchHandler(ipx: IPX): FetchHandler;
220
214
  declare function createIPXNodeHandler(ipx: IPX): NodeHttpHandler;
221
215
  declare function serveIPX(ipx: IPX, opts?: Omit<ServerOptions, "fetch">): Server;
222
- //#endregion
223
- //#region src/storage/http.d.ts
224
216
  type HTTPStorageOptions = {
225
217
  /**
226
218
  * Custom options for fetch operations, such as headers or method overrides.
@@ -257,8 +249,6 @@ type HTTPStorageOptions = {
257
249
  * @throws {H3Error} If validation of the requested URL fails due to a missing hostname or denied host access. See {@link H3Error}.
258
250
  */
259
251
  declare function ipxHttpStorage(_options?: HTTPStorageOptions): IPXStorage;
260
- //#endregion
261
- //#region src/storage/node-fs.d.ts
262
252
  type NodeFSSOptions = {
263
253
  /**
264
254
  * The directory or list of directories from which to serve files. If not specified, the current directory is used by default.
@@ -280,8 +270,6 @@ type NodeFSSOptions = {
280
270
  * @throws {H3Error} If there is a problem accessing the file system module or resolving/reading files. See {@link H3Error}.
281
271
  */
282
272
  declare function ipxFSStorage(_options?: NodeFSSOptions): IPXStorage;
283
- //#endregion
284
- //#region src/storage/unstorage.d.ts
285
273
  type UnstorageIPXStorageOptions = {
286
274
  /**
287
275
  * Optional prefix to be placed in front of each storage key, which can help to name or categorise stored items.
@@ -299,5 +287,4 @@ type UnstorageIPXStorageOptions = {
299
287
  * @throws {H3Error} If there is a problem retrieving or converting the storage data, detailed error information is thrown. See {@link H3Error}.
300
288
  */
301
289
  declare function unstorageToIPXStorage(storage: Storage | Driver, _options?: UnstorageIPXStorageOptions | string): IPXStorage;
302
- //#endregion
303
290
  export { type HTTPStorageOptions, type Handler, type HandlerContext, type IPX, type IPXModifiers, type IPXOptions, type IPXStorage, type IPXStorageMeta, type IPXStorageOptions, type NodeFSSOptions, type UnstorageIPXStorageOptions, createIPX, createIPXFetchHandler, createIPXNodeHandler, ipxFSStorage, ipxHttpStorage, serveIPX, unstorageToIPXStorage };
package/dist/index.mjs CHANGED
@@ -1,19 +1,5 @@
1
- import "./_chunks/rolldown-runtime.mjs";
2
- import { t as HTTPError } from "./_chunks/libs/h3.mjs";
3
- import { a as serveIPX, i as createIPXNodeHandler, n as ipxHttpStorage, o as createIPX, r as createIPXFetchHandler, t as ipxFSStorage } from "./_chunks/node-fs.mjs";
4
- import "./_chunks/libs/etag.mjs";
5
- import "./_chunks/libs/@fastify/accept-negotiator.mjs";
6
-
7
- //#region src/storage/unstorage.ts
8
- /**
9
- * Adapts an Unstorage driver or storage system to comply with the IPXStorage interface required by IPX.
10
- * This allows various Unstorage-compatible storage systems to be used to manage image data with IPX.
11
- *
12
- * @param {Storage | Driver} storage - The Unstorage driver or storage instance to adapt. See {@link Storage} and {@link Driver}.
13
- * @param {UnstorageIPXStorageOptions | string} [_options={}] - Configuration options for the adapter, which can be a simple string prefix or an options object. See {@link UnstorageIPXStorageOptions}.
14
- * @returns {IPXStorage}. An IPXStorage compliant object that implements the necessary methods to interact with the provided unstorage driver or storage system. See {@link IPXStorage}.
15
- * @throws {H3Error} If there is a problem retrieving or converting the storage data, detailed error information is thrown. See {@link H3Error}.
16
- */
1
+ import { HTTPError } from "./_chunks/libs/h3.mjs";
2
+ import { createIPX, createIPXFetchHandler, createIPXNodeHandler, ipxFSStorage, ipxHttpStorage, serveIPX } from "./_chunks/node-fs.mjs";
17
3
  function unstorageToIPXStorage(storage, _options = {}) {
18
4
  const options = typeof _options === "string" ? { prefix: _options } : _options;
19
5
  const resolveKey = (id) => options.prefix ? `${options.prefix}:${id}` : id;
@@ -43,6 +29,4 @@ function unstorageToIPXStorage(storage, _options = {}) {
43
29
  }
44
30
  };
45
31
  }
46
-
47
- //#endregion
48
- export { createIPX, createIPXFetchHandler, createIPXNodeHandler, ipxFSStorage, ipxHttpStorage, serveIPX, unstorageToIPXStorage };
32
+ export { createIPX, createIPXFetchHandler, createIPXNodeHandler, ipxFSStorage, ipxHttpStorage, serveIPX, unstorageToIPXStorage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ipx",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.2",
4
4
  "description": "High performance, secure and easy-to-use image optimizer.",
5
5
  "repository": "unjs/ipx",
6
6
  "license": "MIT",
@@ -30,29 +30,29 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "pathe": "^2.0.3",
33
- "sharp": "^0.34.5",
34
- "srvx": "^0.9.7"
33
+ "sharp": "^0.35.2",
34
+ "srvx": "^0.11.17"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@fastify/accept-negotiator": "^2.0.1",
38
38
  "@types/etag": "^1.8.4",
39
39
  "@types/is-valid-path": "^0.1.2",
40
- "@vitest/coverage-v8": "^4.0.15",
41
- "automd": "^0.4.2",
40
+ "@vitest/coverage-v8": "^4.1.9",
41
+ "automd": "^0.4.3",
42
42
  "changelogen": "^0.6.2",
43
- "eslint": "^9.39.1",
44
- "eslint-config-unjs": "^0.5.0",
43
+ "eslint": "^10.5.0",
44
+ "eslint-config-unjs": "^0.6.2",
45
45
  "etag": "^1.8.1",
46
- "h3": "^2.0.1-rc.5",
46
+ "h3": "2.0.1-rc.22",
47
47
  "image-meta": "^0.2.2",
48
- "obuild": "^0.4.7",
49
- "oxc-minify": "^0.101.0",
50
- "prettier": "^3.7.4",
51
- "svgo": "^4.0.0",
52
- "typescript": "^5.9.3",
53
- "ufo": "^1.6.1",
54
- "unstorage": "^1.17.3",
55
- "vitest": "^4.0.15"
48
+ "obuild": "^0.4.37",
49
+ "oxc-minify": "^0.137.0",
50
+ "prettier": "^3.8.4",
51
+ "svgo": "^4.0.1",
52
+ "typescript": "^6.0.3",
53
+ "ufo": "^1.6.4",
54
+ "unstorage": "^1.17.5",
55
+ "vitest": "^4.1.9"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "unstorage": "*"
@@ -62,5 +62,5 @@
62
62
  "optional": true
63
63
  }
64
64
  },
65
- "packageManager": "pnpm@10.24.0"
65
+ "packageManager": "pnpm@11.9.0"
66
66
  }