ipx 3.1.0 → 4.0.0-alpha.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.
@@ -0,0 +1,46 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region rolldown:runtime
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ 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" });
21
+ }
22
+ return target;
23
+ };
24
+ 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
+ }
35
+ }
36
+ return to;
37
+ };
38
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
39
+ value: mod,
40
+ enumerable: true
41
+ }) : 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 };
@@ -0,0 +1,11 @@
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
+
9
+ export default require_svgo_node();
10
+
11
+ export { };
package/dist/cli.d.mts CHANGED
@@ -1,2 +1 @@
1
-
2
- export { };
1
+ export { };
package/dist/cli.mjs CHANGED
@@ -1,61 +1,79 @@
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.C8X6338M.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 "./_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";
6
+ import { parseArgs } from "node:util";
14
7
 
15
- const name = "ipx";
16
- const version = "3.1.0";
17
- const description = "High performance, secure and easy-to-use image optimizer.";
8
+ //#region package.json
9
+ var name = "ipx";
10
+ var version = "4.0.0-alpha.0";
18
11
 
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
- }
12
+ //#endregion
13
+ //#region src/cli.ts
14
+ const { positionals, values } = parseArgs({
15
+ allowPositionals: true,
16
+ options: {
17
+ dir: { type: "string" },
18
+ domains: { type: "string" },
19
+ port: { type: "string" },
20
+ host: { type: "string" },
21
+ help: {
22
+ type: "boolean",
23
+ short: "h"
24
+ },
25
+ version: {
26
+ type: "boolean",
27
+ short: "v"
28
+ }
29
+ }
50
30
  });
51
- const main = defineCommand({
52
- meta: {
53
- name,
54
- version,
55
- description
56
- },
57
- subCommands: {
58
- serve
59
- }
60
- });
61
- runMain(main);
31
+ const [command] = positionals;
32
+ if (values.version) {
33
+ console.log(`${name} ${version}`);
34
+ process.exit(0);
35
+ }
36
+ if (values.help || !command) {
37
+ printHelp();
38
+ process.exit(0);
39
+ }
40
+ switch (command) {
41
+ case "serve":
42
+ await runServe(values);
43
+ break;
44
+ default:
45
+ console.error(`Unknown command: ${command}\n`);
46
+ printHelp();
47
+ process.exit(1);
48
+ }
49
+ async function runServe(args) {
50
+ await serveIPX(createIPX({
51
+ storage: ipxFSStorage({ dir: args.dir ?? process.env.IPX_FS_DIR ?? process.cwd() }),
52
+ httpStorage: ipxHttpStorage({ domains: args.domains ?? process.env.IPX_HTTP_DOMAINS })
53
+ }), {
54
+ port: Number(args.port ?? process.env.PORT ?? 3e3),
55
+ hostname: args.host ?? process.env.HOST ?? "0.0.0.0"
56
+ }).ready();
57
+ }
58
+ function printHelp() {
59
+ console.log(`
60
+ ${name} ${version}
61
+
62
+ Usage:
63
+ ipx serve [options]
64
+
65
+ Commands:
66
+ serve Start IPX server
67
+
68
+ Options:
69
+ --dir <dir> Directory to serve (ENV: IPX_FS_DIR)
70
+ --domains <list> Allowed domains (comma separated, ENV: IPX_HTTP_DOMAINS)
71
+ --port <number> Port to listen (default: 3000, ENV: PORT)
72
+ --host <host> Host to bind (default: 0.0.0.0, ENV: HOST)
73
+ -h, --help Show help
74
+ -v, --version Show version
75
+ `);
76
+ }
77
+
78
+ //#endregion
79
+ export { };