ipx 3.1.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.
@@ -0,0 +1,42 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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;
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" });
24
+ return target;
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
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
+ });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
37
+ value: mod,
38
+ enumerable: true
39
+ }) : target, mod));
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 };
@@ -0,0 +1,3 @@
1
+ import { require_svgo_node } from "./libs/svgo.mjs";
2
+ export default require_svgo_node();
3
+ export {};
package/dist/cli.d.mts CHANGED
@@ -1,2 +1 @@
1
-
2
- export { };
1
+ export { };
package/dist/cli.mjs CHANGED
@@ -1,61 +1,69 @@
1
- import { listen } from 'listhen';
2
- import { defineCommand, runMain } from 'citty';
3
- import { getArgs, parseArgs } from 'listhen/cli';
4
- import { c as createIPX, i as ipxHttpStorage, g as ipxFSStorage, e as createIPXNodeServer } from './shared/ipx.CXJeaylD.mjs';
5
- import 'defu';
6
- import 'ufo';
7
- import 'h3';
8
- import 'image-meta';
9
- import 'destr';
10
- import '@fastify/accept-negotiator';
11
- import 'etag';
12
- import 'ofetch';
13
- import 'pathe';
1
+ #!/usr/bin/env node
2
+ import { createIPX, ipxFSStorage, ipxHttpStorage, serveIPX } from "./_chunks/node-fs.mjs";
3
+ import { parseArgs } from "node:util";
4
+ var name = "ipx";
5
+ var version = "4.0.0-alpha.1";
6
+ const { positionals, values } = parseArgs({
7
+ allowPositionals: true,
8
+ options: {
9
+ dir: { type: "string" },
10
+ domains: { type: "string" },
11
+ port: { type: "string" },
12
+ host: { type: "string" },
13
+ help: {
14
+ type: "boolean",
15
+ short: "h"
16
+ },
17
+ version: {
18
+ type: "boolean",
19
+ short: "v"
20
+ }
21
+ }
22
+ });
23
+ const [command] = positionals;
24
+ if (values.version) {
25
+ console.log(`${name} ${version}`);
26
+ process.exit(0);
27
+ }
28
+ if (values.help || !command) {
29
+ printHelp();
30
+ process.exit(0);
31
+ }
32
+ switch (command) {
33
+ case "serve":
34
+ await runServe(values);
35
+ break;
36
+ default:
37
+ console.error(`Unknown command: ${command}\n`);
38
+ printHelp();
39
+ process.exit(1);
40
+ }
41
+ async function runServe(args) {
42
+ await serveIPX(createIPX({
43
+ storage: ipxFSStorage({ dir: args.dir ?? process.env.IPX_FS_DIR ?? process.cwd() }),
44
+ httpStorage: ipxHttpStorage({ domains: args.domains ?? process.env.IPX_HTTP_DOMAINS })
45
+ }), {
46
+ port: Number(args.port ?? process.env.PORT ?? 3e3),
47
+ hostname: args.host ?? process.env.HOST ?? "0.0.0.0"
48
+ }).ready();
49
+ }
50
+ function printHelp() {
51
+ console.log(`
52
+ ${name} ${version}
14
53
 
15
- const name = "ipx";
16
- const version = "3.1.1";
17
- const description = "High performance, secure and easy-to-use image optimizer.";
54
+ Usage:
55
+ ipx serve [options]
18
56
 
19
- const serve = defineCommand({
20
- meta: {
21
- description: "Start IPX Server"
22
- },
23
- args: {
24
- dir: {
25
- type: "string",
26
- required: false,
27
- description: "Directory to serve (default: current directory) ENV: IPX_FS_DIR"
28
- },
29
- domains: {
30
- type: "string",
31
- required: false,
32
- description: "Allowed domains (comma separated) ENV: IPX_HTTP_DOMAINS"
33
- },
34
- ...getArgs()
35
- },
36
- async run({ args }) {
37
- const ipx = createIPX({
38
- storage: ipxFSStorage({
39
- dir: args.dir
40
- }),
41
- httpStorage: ipxHttpStorage({
42
- domains: args.domains
43
- })
44
- });
45
- await listen(createIPXNodeServer(ipx), {
46
- name: "IPX",
47
- ...parseArgs(args)
48
- });
49
- }
50
- });
51
- const main = defineCommand({
52
- meta: {
53
- name,
54
- version,
55
- description
56
- },
57
- subCommands: {
58
- serve
59
- }
60
- });
61
- runMain(main);
57
+ Commands:
58
+ serve Start IPX server
59
+
60
+ Options:
61
+ --dir <dir> Directory to serve (ENV: IPX_FS_DIR)
62
+ --domains <list> Allowed domains (comma separated, ENV: IPX_HTTP_DOMAINS)
63
+ --port <number> Port to listen (default: 3000, ENV: PORT)
64
+ --host <host> Host to bind (default: 0.0.0.0, ENV: HOST)
65
+ -h, --help Show help
66
+ -v, --version Show version
67
+ `);
68
+ }
69
+ export {};