feat: init
This commit is contained in:
1071
node_modules/listhen/dist/chunks/xdg-open.cjs
generated
vendored
Normal file
1071
node_modules/listhen/dist/chunks/xdg-open.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1069
node_modules/listhen/dist/chunks/xdg-open.mjs
generated
vendored
Normal file
1069
node_modules/listhen/dist/chunks/xdg-open.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
177
node_modules/listhen/dist/cli.cjs
generated
vendored
Normal file
177
node_modules/listhen/dist/cli.cjs
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
'use strict';
|
||||
|
||||
const citty = require('citty');
|
||||
const pathe = require('pathe');
|
||||
const index = require('./index.cjs');
|
||||
require('node:http');
|
||||
require('node:https');
|
||||
require('node:util');
|
||||
require('get-port-please');
|
||||
require('http-shutdown');
|
||||
require('consola');
|
||||
require('defu');
|
||||
require('consola/utils');
|
||||
require('uqr');
|
||||
require('node:child_process');
|
||||
require('node:fs');
|
||||
require('node:os');
|
||||
require('node:path');
|
||||
require('std-env');
|
||||
require('node-forge');
|
||||
require('node:fs/promises');
|
||||
require('mlly');
|
||||
|
||||
const name = "listhen";
|
||||
const version = "1.8.0";
|
||||
const description = "👂 Elegant HTTP Listener";
|
||||
|
||||
const main = citty.defineCommand({
|
||||
meta: {
|
||||
name,
|
||||
description,
|
||||
version
|
||||
},
|
||||
args: {
|
||||
cwd: {
|
||||
type: "string",
|
||||
description: "Current working directory"
|
||||
},
|
||||
entry: {
|
||||
type: "positional",
|
||||
description: "Listener entry file (./app.ts)",
|
||||
required: true
|
||||
},
|
||||
name: {
|
||||
type: "string",
|
||||
description: "Name to use in the banner"
|
||||
},
|
||||
baseURL: {
|
||||
type: "string",
|
||||
description: "Base URL to use"
|
||||
},
|
||||
watch: {
|
||||
type: "boolean",
|
||||
description: "Watch for changes",
|
||||
alias: "w"
|
||||
},
|
||||
ws: {
|
||||
type: "boolean",
|
||||
description: "Enable Experimental WebSocket support"
|
||||
},
|
||||
...getArgs()
|
||||
},
|
||||
async run({ args }) {
|
||||
const opts = {
|
||||
...args,
|
||||
...parseArgs(args),
|
||||
baseURL: args.baseURL,
|
||||
name: args.name
|
||||
};
|
||||
const entry = pathe.isAbsolute(args.entry) || args.entry.startsWith(".") ? args.entry : `./${args.entry}`;
|
||||
if (args.watch) {
|
||||
await index.listenAndWatch(entry, opts);
|
||||
} else {
|
||||
const devServer = await index.createDevServer(entry, opts);
|
||||
await index.listen(devServer.nodeListener, {
|
||||
...opts,
|
||||
_entry: devServer._entry,
|
||||
ws: opts.ws ? devServer._ws : void 0
|
||||
});
|
||||
await devServer.reload(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
const runMain = () => citty.runMain(main);
|
||||
function getArgs() {
|
||||
return {
|
||||
port: {
|
||||
type: "string",
|
||||
description: "Port to listen on (use `PORT` environment variable to override)"
|
||||
},
|
||||
host: {
|
||||
description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)"
|
||||
},
|
||||
clipboard: {
|
||||
type: "boolean",
|
||||
description: "Copy the URL to the clipboard"
|
||||
},
|
||||
open: {
|
||||
type: "boolean",
|
||||
description: "Open the URL in the browser"
|
||||
},
|
||||
https: {
|
||||
type: "boolean",
|
||||
description: "Enable HTTPS"
|
||||
},
|
||||
"https.cert": {
|
||||
type: "string",
|
||||
description: "Path to TLS certificate used with HTTPS in PEM format"
|
||||
},
|
||||
"https.key": {
|
||||
type: "string",
|
||||
description: "Path to TLS key used with HTTPS in PEM format"
|
||||
},
|
||||
"https.pfx": {
|
||||
type: "string",
|
||||
description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key"
|
||||
},
|
||||
"https.passphrase": {
|
||||
type: "string",
|
||||
description: "Passphrase used for TLS key or keystore"
|
||||
},
|
||||
"https.validityDays": {
|
||||
type: "string",
|
||||
description: "Validity in days of the autogenerated TLS certificate (https: true)"
|
||||
},
|
||||
"https.domains": {
|
||||
type: "string",
|
||||
description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)"
|
||||
},
|
||||
publicURL: {
|
||||
type: "string",
|
||||
description: "Displayed public URL (used for QR code)",
|
||||
required: false
|
||||
},
|
||||
qr: {
|
||||
type: "boolean",
|
||||
description: "Display The QR code of public URL when available",
|
||||
required: false
|
||||
},
|
||||
public: {
|
||||
type: "boolean",
|
||||
description: "Listen to all network interfaces",
|
||||
required: false
|
||||
},
|
||||
tunnel: {
|
||||
type: "boolean",
|
||||
description: "Open a tunnel using https://github.com/unjs/untun",
|
||||
required: false
|
||||
}
|
||||
};
|
||||
}
|
||||
function parseArgs(args) {
|
||||
return {
|
||||
port: args.port,
|
||||
// prettier-ignore
|
||||
hostname: typeof args.host === "string" ? args.host : args.host === true ? "" : void 0,
|
||||
clipboard: args.clipboard,
|
||||
open: args.open,
|
||||
qr: args.qr,
|
||||
publicURL: args.publicURL,
|
||||
public: args.public,
|
||||
tunnel: args.tunnel,
|
||||
https: args.https ? {
|
||||
cert: args["https.cert"],
|
||||
key: args["https.key"],
|
||||
pfx: args["https.pfx"],
|
||||
passphrase: args["https.passphrase"],
|
||||
validityDays: args["https.validityDays"] ? +args["https.validityDays"] : void 0,
|
||||
domains: args["https.domains"] ? args["https.domains"].split(",") : void 0
|
||||
} : false
|
||||
};
|
||||
}
|
||||
|
||||
exports.getArgs = getArgs;
|
||||
exports.main = main;
|
||||
exports.parseArgs = parseArgs;
|
||||
exports.runMain = runMain;
|
||||
172
node_modules/listhen/dist/cli.d.cts
generated
vendored
Normal file
172
node_modules/listhen/dist/cli.d.cts
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
import * as citty from 'citty';
|
||||
import { ParsedArgs } from 'citty';
|
||||
import { L as ListenOptions } from './shared/listhen.1c46e31d.cjs';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:net';
|
||||
import 'get-port-please';
|
||||
import 'crossws/adapters/node';
|
||||
|
||||
declare const main: citty.CommandDef<{
|
||||
port: {
|
||||
readonly type: "string";
|
||||
readonly description: "Port to listen on (use `PORT` environment variable to override)";
|
||||
};
|
||||
host: {
|
||||
readonly description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)";
|
||||
};
|
||||
clipboard: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Copy the URL to the clipboard";
|
||||
};
|
||||
open: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open the URL in the browser";
|
||||
};
|
||||
https: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Enable HTTPS";
|
||||
};
|
||||
"https.cert": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS certificate used with HTTPS in PEM format";
|
||||
};
|
||||
"https.key": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS key used with HTTPS in PEM format";
|
||||
};
|
||||
"https.pfx": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key";
|
||||
};
|
||||
"https.passphrase": {
|
||||
readonly type: "string";
|
||||
readonly description: "Passphrase used for TLS key or keystore";
|
||||
};
|
||||
"https.validityDays": {
|
||||
readonly type: "string";
|
||||
readonly description: "Validity in days of the autogenerated TLS certificate (https: true)";
|
||||
};
|
||||
"https.domains": {
|
||||
readonly type: "string";
|
||||
readonly description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)";
|
||||
};
|
||||
publicURL: {
|
||||
readonly type: "string";
|
||||
readonly description: "Displayed public URL (used for QR code)";
|
||||
readonly required: false;
|
||||
};
|
||||
qr: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Display The QR code of public URL when available";
|
||||
readonly required: false;
|
||||
};
|
||||
public: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Listen to all network interfaces";
|
||||
readonly required: false;
|
||||
};
|
||||
tunnel: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open a tunnel using https://github.com/unjs/untun";
|
||||
readonly required: false;
|
||||
};
|
||||
cwd: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
entry: {
|
||||
type: "positional";
|
||||
description: string;
|
||||
required: true;
|
||||
};
|
||||
name: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
baseURL: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
watch: {
|
||||
type: "boolean";
|
||||
description: string;
|
||||
alias: string;
|
||||
};
|
||||
ws: {
|
||||
type: "boolean";
|
||||
description: string;
|
||||
};
|
||||
}>;
|
||||
declare const runMain: () => Promise<void>;
|
||||
/** Returns unjs/citty compatible args object */
|
||||
declare function getArgs(): {
|
||||
readonly port: {
|
||||
readonly type: "string";
|
||||
readonly description: "Port to listen on (use `PORT` environment variable to override)";
|
||||
};
|
||||
readonly host: {
|
||||
readonly description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)";
|
||||
};
|
||||
readonly clipboard: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Copy the URL to the clipboard";
|
||||
};
|
||||
readonly open: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open the URL in the browser";
|
||||
};
|
||||
readonly https: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Enable HTTPS";
|
||||
};
|
||||
readonly "https.cert": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS certificate used with HTTPS in PEM format";
|
||||
};
|
||||
readonly "https.key": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS key used with HTTPS in PEM format";
|
||||
};
|
||||
readonly "https.pfx": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key";
|
||||
};
|
||||
readonly "https.passphrase": {
|
||||
readonly type: "string";
|
||||
readonly description: "Passphrase used for TLS key or keystore";
|
||||
};
|
||||
readonly "https.validityDays": {
|
||||
readonly type: "string";
|
||||
readonly description: "Validity in days of the autogenerated TLS certificate (https: true)";
|
||||
};
|
||||
readonly "https.domains": {
|
||||
readonly type: "string";
|
||||
readonly description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)";
|
||||
};
|
||||
readonly publicURL: {
|
||||
readonly type: "string";
|
||||
readonly description: "Displayed public URL (used for QR code)";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly qr: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Display The QR code of public URL when available";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly public: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Listen to all network interfaces";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly tunnel: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open a tunnel using https://github.com/unjs/untun";
|
||||
readonly required: false;
|
||||
};
|
||||
};
|
||||
type ParsedListhenArgs = ParsedArgs<ReturnType<typeof getArgs>>;
|
||||
/** Convert unjs/citty compatible args to listhen options */
|
||||
declare function parseArgs(args: ParsedListhenArgs): Partial<ListenOptions>;
|
||||
|
||||
export { getArgs, main, parseArgs, runMain };
|
||||
172
node_modules/listhen/dist/cli.d.mts
generated
vendored
Normal file
172
node_modules/listhen/dist/cli.d.mts
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
import * as citty from 'citty';
|
||||
import { ParsedArgs } from 'citty';
|
||||
import { L as ListenOptions } from './shared/listhen.1c46e31d.mjs';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:net';
|
||||
import 'get-port-please';
|
||||
import 'crossws/adapters/node';
|
||||
|
||||
declare const main: citty.CommandDef<{
|
||||
port: {
|
||||
readonly type: "string";
|
||||
readonly description: "Port to listen on (use `PORT` environment variable to override)";
|
||||
};
|
||||
host: {
|
||||
readonly description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)";
|
||||
};
|
||||
clipboard: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Copy the URL to the clipboard";
|
||||
};
|
||||
open: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open the URL in the browser";
|
||||
};
|
||||
https: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Enable HTTPS";
|
||||
};
|
||||
"https.cert": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS certificate used with HTTPS in PEM format";
|
||||
};
|
||||
"https.key": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS key used with HTTPS in PEM format";
|
||||
};
|
||||
"https.pfx": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key";
|
||||
};
|
||||
"https.passphrase": {
|
||||
readonly type: "string";
|
||||
readonly description: "Passphrase used for TLS key or keystore";
|
||||
};
|
||||
"https.validityDays": {
|
||||
readonly type: "string";
|
||||
readonly description: "Validity in days of the autogenerated TLS certificate (https: true)";
|
||||
};
|
||||
"https.domains": {
|
||||
readonly type: "string";
|
||||
readonly description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)";
|
||||
};
|
||||
publicURL: {
|
||||
readonly type: "string";
|
||||
readonly description: "Displayed public URL (used for QR code)";
|
||||
readonly required: false;
|
||||
};
|
||||
qr: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Display The QR code of public URL when available";
|
||||
readonly required: false;
|
||||
};
|
||||
public: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Listen to all network interfaces";
|
||||
readonly required: false;
|
||||
};
|
||||
tunnel: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open a tunnel using https://github.com/unjs/untun";
|
||||
readonly required: false;
|
||||
};
|
||||
cwd: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
entry: {
|
||||
type: "positional";
|
||||
description: string;
|
||||
required: true;
|
||||
};
|
||||
name: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
baseURL: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
watch: {
|
||||
type: "boolean";
|
||||
description: string;
|
||||
alias: string;
|
||||
};
|
||||
ws: {
|
||||
type: "boolean";
|
||||
description: string;
|
||||
};
|
||||
}>;
|
||||
declare const runMain: () => Promise<void>;
|
||||
/** Returns unjs/citty compatible args object */
|
||||
declare function getArgs(): {
|
||||
readonly port: {
|
||||
readonly type: "string";
|
||||
readonly description: "Port to listen on (use `PORT` environment variable to override)";
|
||||
};
|
||||
readonly host: {
|
||||
readonly description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)";
|
||||
};
|
||||
readonly clipboard: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Copy the URL to the clipboard";
|
||||
};
|
||||
readonly open: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open the URL in the browser";
|
||||
};
|
||||
readonly https: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Enable HTTPS";
|
||||
};
|
||||
readonly "https.cert": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS certificate used with HTTPS in PEM format";
|
||||
};
|
||||
readonly "https.key": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS key used with HTTPS in PEM format";
|
||||
};
|
||||
readonly "https.pfx": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key";
|
||||
};
|
||||
readonly "https.passphrase": {
|
||||
readonly type: "string";
|
||||
readonly description: "Passphrase used for TLS key or keystore";
|
||||
};
|
||||
readonly "https.validityDays": {
|
||||
readonly type: "string";
|
||||
readonly description: "Validity in days of the autogenerated TLS certificate (https: true)";
|
||||
};
|
||||
readonly "https.domains": {
|
||||
readonly type: "string";
|
||||
readonly description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)";
|
||||
};
|
||||
readonly publicURL: {
|
||||
readonly type: "string";
|
||||
readonly description: "Displayed public URL (used for QR code)";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly qr: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Display The QR code of public URL when available";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly public: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Listen to all network interfaces";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly tunnel: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open a tunnel using https://github.com/unjs/untun";
|
||||
readonly required: false;
|
||||
};
|
||||
};
|
||||
type ParsedListhenArgs = ParsedArgs<ReturnType<typeof getArgs>>;
|
||||
/** Convert unjs/citty compatible args to listhen options */
|
||||
declare function parseArgs(args: ParsedListhenArgs): Partial<ListenOptions>;
|
||||
|
||||
export { getArgs, main, parseArgs, runMain };
|
||||
172
node_modules/listhen/dist/cli.d.ts
generated
vendored
Normal file
172
node_modules/listhen/dist/cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
import * as citty from 'citty';
|
||||
import { ParsedArgs } from 'citty';
|
||||
import { L as ListenOptions } from './shared/listhen.1c46e31d.js';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:net';
|
||||
import 'get-port-please';
|
||||
import 'crossws/adapters/node';
|
||||
|
||||
declare const main: citty.CommandDef<{
|
||||
port: {
|
||||
readonly type: "string";
|
||||
readonly description: "Port to listen on (use `PORT` environment variable to override)";
|
||||
};
|
||||
host: {
|
||||
readonly description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)";
|
||||
};
|
||||
clipboard: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Copy the URL to the clipboard";
|
||||
};
|
||||
open: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open the URL in the browser";
|
||||
};
|
||||
https: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Enable HTTPS";
|
||||
};
|
||||
"https.cert": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS certificate used with HTTPS in PEM format";
|
||||
};
|
||||
"https.key": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS key used with HTTPS in PEM format";
|
||||
};
|
||||
"https.pfx": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key";
|
||||
};
|
||||
"https.passphrase": {
|
||||
readonly type: "string";
|
||||
readonly description: "Passphrase used for TLS key or keystore";
|
||||
};
|
||||
"https.validityDays": {
|
||||
readonly type: "string";
|
||||
readonly description: "Validity in days of the autogenerated TLS certificate (https: true)";
|
||||
};
|
||||
"https.domains": {
|
||||
readonly type: "string";
|
||||
readonly description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)";
|
||||
};
|
||||
publicURL: {
|
||||
readonly type: "string";
|
||||
readonly description: "Displayed public URL (used for QR code)";
|
||||
readonly required: false;
|
||||
};
|
||||
qr: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Display The QR code of public URL when available";
|
||||
readonly required: false;
|
||||
};
|
||||
public: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Listen to all network interfaces";
|
||||
readonly required: false;
|
||||
};
|
||||
tunnel: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open a tunnel using https://github.com/unjs/untun";
|
||||
readonly required: false;
|
||||
};
|
||||
cwd: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
entry: {
|
||||
type: "positional";
|
||||
description: string;
|
||||
required: true;
|
||||
};
|
||||
name: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
baseURL: {
|
||||
type: "string";
|
||||
description: string;
|
||||
};
|
||||
watch: {
|
||||
type: "boolean";
|
||||
description: string;
|
||||
alias: string;
|
||||
};
|
||||
ws: {
|
||||
type: "boolean";
|
||||
description: string;
|
||||
};
|
||||
}>;
|
||||
declare const runMain: () => Promise<void>;
|
||||
/** Returns unjs/citty compatible args object */
|
||||
declare function getArgs(): {
|
||||
readonly port: {
|
||||
readonly type: "string";
|
||||
readonly description: "Port to listen on (use `PORT` environment variable to override)";
|
||||
};
|
||||
readonly host: {
|
||||
readonly description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)";
|
||||
};
|
||||
readonly clipboard: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Copy the URL to the clipboard";
|
||||
};
|
||||
readonly open: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open the URL in the browser";
|
||||
};
|
||||
readonly https: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Enable HTTPS";
|
||||
};
|
||||
readonly "https.cert": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS certificate used with HTTPS in PEM format";
|
||||
};
|
||||
readonly "https.key": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to TLS key used with HTTPS in PEM format";
|
||||
};
|
||||
readonly "https.pfx": {
|
||||
readonly type: "string";
|
||||
readonly description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key";
|
||||
};
|
||||
readonly "https.passphrase": {
|
||||
readonly type: "string";
|
||||
readonly description: "Passphrase used for TLS key or keystore";
|
||||
};
|
||||
readonly "https.validityDays": {
|
||||
readonly type: "string";
|
||||
readonly description: "Validity in days of the autogenerated TLS certificate (https: true)";
|
||||
};
|
||||
readonly "https.domains": {
|
||||
readonly type: "string";
|
||||
readonly description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)";
|
||||
};
|
||||
readonly publicURL: {
|
||||
readonly type: "string";
|
||||
readonly description: "Displayed public URL (used for QR code)";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly qr: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Display The QR code of public URL when available";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly public: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Listen to all network interfaces";
|
||||
readonly required: false;
|
||||
};
|
||||
readonly tunnel: {
|
||||
readonly type: "boolean";
|
||||
readonly description: "Open a tunnel using https://github.com/unjs/untun";
|
||||
readonly required: false;
|
||||
};
|
||||
};
|
||||
type ParsedListhenArgs = ParsedArgs<ReturnType<typeof getArgs>>;
|
||||
/** Convert unjs/citty compatible args to listhen options */
|
||||
declare function parseArgs(args: ParsedListhenArgs): Partial<ListenOptions>;
|
||||
|
||||
export { getArgs, main, parseArgs, runMain };
|
||||
172
node_modules/listhen/dist/cli.mjs
generated
vendored
Normal file
172
node_modules/listhen/dist/cli.mjs
generated
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
import { defineCommand, runMain as runMain$1 } from 'citty';
|
||||
import { isAbsolute } from 'pathe';
|
||||
import { listenAndWatch, createDevServer, listen } from './index.mjs';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:util';
|
||||
import 'get-port-please';
|
||||
import 'http-shutdown';
|
||||
import 'consola';
|
||||
import 'defu';
|
||||
import 'consola/utils';
|
||||
import 'uqr';
|
||||
import 'node:child_process';
|
||||
import 'node:fs';
|
||||
import 'node:os';
|
||||
import 'node:path';
|
||||
import 'std-env';
|
||||
import 'node-forge';
|
||||
import 'node:fs/promises';
|
||||
import 'mlly';
|
||||
|
||||
const name = "listhen";
|
||||
const version = "1.8.0";
|
||||
const description = "👂 Elegant HTTP Listener";
|
||||
|
||||
const main = defineCommand({
|
||||
meta: {
|
||||
name,
|
||||
description,
|
||||
version
|
||||
},
|
||||
args: {
|
||||
cwd: {
|
||||
type: "string",
|
||||
description: "Current working directory"
|
||||
},
|
||||
entry: {
|
||||
type: "positional",
|
||||
description: "Listener entry file (./app.ts)",
|
||||
required: true
|
||||
},
|
||||
name: {
|
||||
type: "string",
|
||||
description: "Name to use in the banner"
|
||||
},
|
||||
baseURL: {
|
||||
type: "string",
|
||||
description: "Base URL to use"
|
||||
},
|
||||
watch: {
|
||||
type: "boolean",
|
||||
description: "Watch for changes",
|
||||
alias: "w"
|
||||
},
|
||||
ws: {
|
||||
type: "boolean",
|
||||
description: "Enable Experimental WebSocket support"
|
||||
},
|
||||
...getArgs()
|
||||
},
|
||||
async run({ args }) {
|
||||
const opts = {
|
||||
...args,
|
||||
...parseArgs(args),
|
||||
baseURL: args.baseURL,
|
||||
name: args.name
|
||||
};
|
||||
const entry = isAbsolute(args.entry) || args.entry.startsWith(".") ? args.entry : `./${args.entry}`;
|
||||
if (args.watch) {
|
||||
await listenAndWatch(entry, opts);
|
||||
} else {
|
||||
const devServer = await createDevServer(entry, opts);
|
||||
await listen(devServer.nodeListener, {
|
||||
...opts,
|
||||
_entry: devServer._entry,
|
||||
ws: opts.ws ? devServer._ws : void 0
|
||||
});
|
||||
await devServer.reload(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
const runMain = () => runMain$1(main);
|
||||
function getArgs() {
|
||||
return {
|
||||
port: {
|
||||
type: "string",
|
||||
description: "Port to listen on (use `PORT` environment variable to override)"
|
||||
},
|
||||
host: {
|
||||
description: "Host to listen on. If no value or an empty string provided, will listen on all available interfaces (use `HOST` environment variable to override)"
|
||||
},
|
||||
clipboard: {
|
||||
type: "boolean",
|
||||
description: "Copy the URL to the clipboard"
|
||||
},
|
||||
open: {
|
||||
type: "boolean",
|
||||
description: "Open the URL in the browser"
|
||||
},
|
||||
https: {
|
||||
type: "boolean",
|
||||
description: "Enable HTTPS"
|
||||
},
|
||||
"https.cert": {
|
||||
type: "string",
|
||||
description: "Path to TLS certificate used with HTTPS in PEM format"
|
||||
},
|
||||
"https.key": {
|
||||
type: "string",
|
||||
description: "Path to TLS key used with HTTPS in PEM format"
|
||||
},
|
||||
"https.pfx": {
|
||||
type: "string",
|
||||
description: "Path to PKCS#12 (.p12/.pfx) keystore containing a TLS certificate and Key"
|
||||
},
|
||||
"https.passphrase": {
|
||||
type: "string",
|
||||
description: "Passphrase used for TLS key or keystore"
|
||||
},
|
||||
"https.validityDays": {
|
||||
type: "string",
|
||||
description: "Validity in days of the autogenerated TLS certificate (https: true)"
|
||||
},
|
||||
"https.domains": {
|
||||
type: "string",
|
||||
description: "Comma seperated list of domains and IPs, the autogenerated certificate should be valid for (https: true)"
|
||||
},
|
||||
publicURL: {
|
||||
type: "string",
|
||||
description: "Displayed public URL (used for QR code)",
|
||||
required: false
|
||||
},
|
||||
qr: {
|
||||
type: "boolean",
|
||||
description: "Display The QR code of public URL when available",
|
||||
required: false
|
||||
},
|
||||
public: {
|
||||
type: "boolean",
|
||||
description: "Listen to all network interfaces",
|
||||
required: false
|
||||
},
|
||||
tunnel: {
|
||||
type: "boolean",
|
||||
description: "Open a tunnel using https://github.com/unjs/untun",
|
||||
required: false
|
||||
}
|
||||
};
|
||||
}
|
||||
function parseArgs(args) {
|
||||
return {
|
||||
port: args.port,
|
||||
// prettier-ignore
|
||||
hostname: typeof args.host === "string" ? args.host : args.host === true ? "" : void 0,
|
||||
clipboard: args.clipboard,
|
||||
open: args.open,
|
||||
qr: args.qr,
|
||||
publicURL: args.publicURL,
|
||||
public: args.public,
|
||||
tunnel: args.tunnel,
|
||||
https: args.https ? {
|
||||
cert: args["https.cert"],
|
||||
key: args["https.key"],
|
||||
pfx: args["https.pfx"],
|
||||
passphrase: args["https.passphrase"],
|
||||
validityDays: args["https.validityDays"] ? +args["https.validityDays"] : void 0,
|
||||
domains: args["https.domains"] ? args["https.domains"].split(",") : void 0
|
||||
} : false
|
||||
};
|
||||
}
|
||||
|
||||
export { getArgs, main, parseArgs, runMain };
|
||||
1072
node_modules/listhen/dist/index.cjs
generated
vendored
Normal file
1072
node_modules/listhen/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
44
node_modules/listhen/dist/index.d.cts
generated
vendored
Normal file
44
node_modules/listhen/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { RequestListener } from 'node:http';
|
||||
import { L as ListenOptions, a as Listener } from './shared/listhen.1c46e31d.cjs';
|
||||
export { b as Certificate, C as CrossWSOptions, G as GetURLOptions, H as HTTPSOptions, c as ListenURL, S as ShowURLOptions } from './shared/listhen.1c46e31d.cjs';
|
||||
import { ConsolaInstance } from 'consola';
|
||||
import * as http from 'http';
|
||||
import * as crossws_adapters_node from 'crossws/adapters/node';
|
||||
import * as h3 from 'h3';
|
||||
import * as jiti_lib_types from 'jiti/lib/types';
|
||||
import 'node:https';
|
||||
import 'node:net';
|
||||
import 'get-port-please';
|
||||
|
||||
declare function listen(handle: RequestListener, _options?: Partial<ListenOptions>): Promise<Listener>;
|
||||
|
||||
interface DevServerOptions {
|
||||
cwd?: string;
|
||||
staticDirs?: string[];
|
||||
logger?: ConsolaInstance;
|
||||
ws?: ListenOptions["ws"];
|
||||
}
|
||||
declare function createDevServer(entry: string, options: DevServerOptions): Promise<{
|
||||
cwd: string;
|
||||
resolver: {
|
||||
relative: (path: string) => string;
|
||||
formatRelative: (path: string) => string;
|
||||
import: (id: string, opts?: jiti_lib_types.JitiResolveOptions) => Promise<unknown>;
|
||||
resolve: (id: string) => string;
|
||||
tryResolve: (id: string) => string | undefined;
|
||||
};
|
||||
nodeListener: h3.NodeListener;
|
||||
reload: (_initial?: boolean) => Promise<void>;
|
||||
_ws: false | crossws_adapters_node.NodeOptions | ((req: http.IncomingMessage, head: Buffer) => void) | undefined;
|
||||
_entry: string | undefined;
|
||||
}>;
|
||||
|
||||
interface WatchOptions extends DevServerOptions {
|
||||
cwd?: string;
|
||||
logger?: ConsolaInstance;
|
||||
ignore?: string[];
|
||||
publicDirs?: string[];
|
||||
}
|
||||
declare function listenAndWatch(entry: string, options: Partial<ListenOptions & WatchOptions>): Promise<Listener>;
|
||||
|
||||
export { type DevServerOptions, ListenOptions, Listener, type WatchOptions, createDevServer, listen, listenAndWatch };
|
||||
44
node_modules/listhen/dist/index.d.mts
generated
vendored
Normal file
44
node_modules/listhen/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { RequestListener } from 'node:http';
|
||||
import { L as ListenOptions, a as Listener } from './shared/listhen.1c46e31d.mjs';
|
||||
export { b as Certificate, C as CrossWSOptions, G as GetURLOptions, H as HTTPSOptions, c as ListenURL, S as ShowURLOptions } from './shared/listhen.1c46e31d.mjs';
|
||||
import { ConsolaInstance } from 'consola';
|
||||
import * as http from 'http';
|
||||
import * as crossws_adapters_node from 'crossws/adapters/node';
|
||||
import * as h3 from 'h3';
|
||||
import * as jiti_lib_types from 'jiti/lib/types';
|
||||
import 'node:https';
|
||||
import 'node:net';
|
||||
import 'get-port-please';
|
||||
|
||||
declare function listen(handle: RequestListener, _options?: Partial<ListenOptions>): Promise<Listener>;
|
||||
|
||||
interface DevServerOptions {
|
||||
cwd?: string;
|
||||
staticDirs?: string[];
|
||||
logger?: ConsolaInstance;
|
||||
ws?: ListenOptions["ws"];
|
||||
}
|
||||
declare function createDevServer(entry: string, options: DevServerOptions): Promise<{
|
||||
cwd: string;
|
||||
resolver: {
|
||||
relative: (path: string) => string;
|
||||
formatRelative: (path: string) => string;
|
||||
import: (id: string, opts?: jiti_lib_types.JitiResolveOptions) => Promise<unknown>;
|
||||
resolve: (id: string) => string;
|
||||
tryResolve: (id: string) => string | undefined;
|
||||
};
|
||||
nodeListener: h3.NodeListener;
|
||||
reload: (_initial?: boolean) => Promise<void>;
|
||||
_ws: false | crossws_adapters_node.NodeOptions | ((req: http.IncomingMessage, head: Buffer) => void) | undefined;
|
||||
_entry: string | undefined;
|
||||
}>;
|
||||
|
||||
interface WatchOptions extends DevServerOptions {
|
||||
cwd?: string;
|
||||
logger?: ConsolaInstance;
|
||||
ignore?: string[];
|
||||
publicDirs?: string[];
|
||||
}
|
||||
declare function listenAndWatch(entry: string, options: Partial<ListenOptions & WatchOptions>): Promise<Listener>;
|
||||
|
||||
export { type DevServerOptions, ListenOptions, Listener, type WatchOptions, createDevServer, listen, listenAndWatch };
|
||||
44
node_modules/listhen/dist/index.d.ts
generated
vendored
Normal file
44
node_modules/listhen/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { RequestListener } from 'node:http';
|
||||
import { L as ListenOptions, a as Listener } from './shared/listhen.1c46e31d.js';
|
||||
export { b as Certificate, C as CrossWSOptions, G as GetURLOptions, H as HTTPSOptions, c as ListenURL, S as ShowURLOptions } from './shared/listhen.1c46e31d.js';
|
||||
import { ConsolaInstance } from 'consola';
|
||||
import * as http from 'http';
|
||||
import * as crossws_adapters_node from 'crossws/adapters/node';
|
||||
import * as h3 from 'h3';
|
||||
import * as jiti_lib_types from 'jiti/lib/types';
|
||||
import 'node:https';
|
||||
import 'node:net';
|
||||
import 'get-port-please';
|
||||
|
||||
declare function listen(handle: RequestListener, _options?: Partial<ListenOptions>): Promise<Listener>;
|
||||
|
||||
interface DevServerOptions {
|
||||
cwd?: string;
|
||||
staticDirs?: string[];
|
||||
logger?: ConsolaInstance;
|
||||
ws?: ListenOptions["ws"];
|
||||
}
|
||||
declare function createDevServer(entry: string, options: DevServerOptions): Promise<{
|
||||
cwd: string;
|
||||
resolver: {
|
||||
relative: (path: string) => string;
|
||||
formatRelative: (path: string) => string;
|
||||
import: (id: string, opts?: jiti_lib_types.JitiResolveOptions) => Promise<unknown>;
|
||||
resolve: (id: string) => string;
|
||||
tryResolve: (id: string) => string | undefined;
|
||||
};
|
||||
nodeListener: h3.NodeListener;
|
||||
reload: (_initial?: boolean) => Promise<void>;
|
||||
_ws: false | crossws_adapters_node.NodeOptions | ((req: http.IncomingMessage, head: Buffer) => void) | undefined;
|
||||
_entry: string | undefined;
|
||||
}>;
|
||||
|
||||
interface WatchOptions extends DevServerOptions {
|
||||
cwd?: string;
|
||||
logger?: ConsolaInstance;
|
||||
ignore?: string[];
|
||||
publicDirs?: string[];
|
||||
}
|
||||
declare function listenAndWatch(entry: string, options: Partial<ListenOptions & WatchOptions>): Promise<Listener>;
|
||||
|
||||
export { type DevServerOptions, ListenOptions, Listener, type WatchOptions, createDevServer, listen, listenAndWatch };
|
||||
1058
node_modules/listhen/dist/index.mjs
generated
vendored
Normal file
1058
node_modules/listhen/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
82
node_modules/listhen/dist/shared/listhen.1c46e31d.d.cts
generated
vendored
Normal file
82
node_modules/listhen/dist/shared/listhen.1c46e31d.d.cts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { IncomingMessage, Server } from 'node:http';
|
||||
import { Server as Server$1 } from 'node:https';
|
||||
import { AddressInfo } from 'node:net';
|
||||
import { GetPortInput } from 'get-port-please';
|
||||
import { NodeOptions } from 'crossws/adapters/node';
|
||||
|
||||
type CrossWSOptions = NodeOptions;
|
||||
interface Certificate {
|
||||
key: string;
|
||||
cert: string;
|
||||
passphrase?: string;
|
||||
}
|
||||
interface HTTPSOptions {
|
||||
cert?: string;
|
||||
key?: string;
|
||||
pfx?: string;
|
||||
passphrase?: string;
|
||||
validityDays?: number;
|
||||
domains?: string[];
|
||||
}
|
||||
interface ListenOptions {
|
||||
name: string;
|
||||
port: GetPortInput;
|
||||
hostname: string;
|
||||
showURL: boolean;
|
||||
baseURL: string;
|
||||
open: boolean;
|
||||
https: boolean | HTTPSOptions;
|
||||
clipboard: boolean;
|
||||
isTest: boolean;
|
||||
isProd: boolean;
|
||||
autoClose: boolean;
|
||||
_entry?: string;
|
||||
/**
|
||||
* Used as main public url to display
|
||||
* @default The first public IPV4 address listening to
|
||||
*/
|
||||
publicURL?: string;
|
||||
/**
|
||||
* Print QR Code for public IPv4 address
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
qr?: boolean;
|
||||
/**
|
||||
* When enabled, listhen tries to listen to all network interfaces
|
||||
*
|
||||
* @default `false` for development and `true` for production
|
||||
*/
|
||||
public: boolean;
|
||||
/**
|
||||
* Open a tunnel using https://github.com/unjs/untun
|
||||
*/
|
||||
tunnel?: boolean;
|
||||
/**
|
||||
* WebSocket Upgrade Handler
|
||||
*
|
||||
* Input can be an upgrade handler or CrossWS options
|
||||
*
|
||||
* @experimental CrossWS usage is subject to change
|
||||
* @see https://github.com/unjs/crossws
|
||||
*/
|
||||
ws?: boolean | CrossWSOptions | ((req: IncomingMessage, head: Buffer) => void);
|
||||
}
|
||||
type GetURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "publicURL">;
|
||||
type ShowURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "name" | "publicURL" | "qr">;
|
||||
interface ListenURL {
|
||||
url: string;
|
||||
type: "local" | "network" | "tunnel";
|
||||
}
|
||||
interface Listener {
|
||||
url: string;
|
||||
address: AddressInfo;
|
||||
server: Server | Server$1;
|
||||
https: false | Certificate;
|
||||
close: () => Promise<void>;
|
||||
open: () => Promise<void>;
|
||||
showURL: (options?: ShowURLOptions) => Promise<void>;
|
||||
getURLs: (options?: GetURLOptions) => Promise<ListenURL[]>;
|
||||
}
|
||||
|
||||
export type { CrossWSOptions as C, GetURLOptions as G, HTTPSOptions as H, ListenOptions as L, ShowURLOptions as S, Listener as a, Certificate as b, ListenURL as c };
|
||||
82
node_modules/listhen/dist/shared/listhen.1c46e31d.d.mts
generated
vendored
Normal file
82
node_modules/listhen/dist/shared/listhen.1c46e31d.d.mts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { IncomingMessage, Server } from 'node:http';
|
||||
import { Server as Server$1 } from 'node:https';
|
||||
import { AddressInfo } from 'node:net';
|
||||
import { GetPortInput } from 'get-port-please';
|
||||
import { NodeOptions } from 'crossws/adapters/node';
|
||||
|
||||
type CrossWSOptions = NodeOptions;
|
||||
interface Certificate {
|
||||
key: string;
|
||||
cert: string;
|
||||
passphrase?: string;
|
||||
}
|
||||
interface HTTPSOptions {
|
||||
cert?: string;
|
||||
key?: string;
|
||||
pfx?: string;
|
||||
passphrase?: string;
|
||||
validityDays?: number;
|
||||
domains?: string[];
|
||||
}
|
||||
interface ListenOptions {
|
||||
name: string;
|
||||
port: GetPortInput;
|
||||
hostname: string;
|
||||
showURL: boolean;
|
||||
baseURL: string;
|
||||
open: boolean;
|
||||
https: boolean | HTTPSOptions;
|
||||
clipboard: boolean;
|
||||
isTest: boolean;
|
||||
isProd: boolean;
|
||||
autoClose: boolean;
|
||||
_entry?: string;
|
||||
/**
|
||||
* Used as main public url to display
|
||||
* @default The first public IPV4 address listening to
|
||||
*/
|
||||
publicURL?: string;
|
||||
/**
|
||||
* Print QR Code for public IPv4 address
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
qr?: boolean;
|
||||
/**
|
||||
* When enabled, listhen tries to listen to all network interfaces
|
||||
*
|
||||
* @default `false` for development and `true` for production
|
||||
*/
|
||||
public: boolean;
|
||||
/**
|
||||
* Open a tunnel using https://github.com/unjs/untun
|
||||
*/
|
||||
tunnel?: boolean;
|
||||
/**
|
||||
* WebSocket Upgrade Handler
|
||||
*
|
||||
* Input can be an upgrade handler or CrossWS options
|
||||
*
|
||||
* @experimental CrossWS usage is subject to change
|
||||
* @see https://github.com/unjs/crossws
|
||||
*/
|
||||
ws?: boolean | CrossWSOptions | ((req: IncomingMessage, head: Buffer) => void);
|
||||
}
|
||||
type GetURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "publicURL">;
|
||||
type ShowURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "name" | "publicURL" | "qr">;
|
||||
interface ListenURL {
|
||||
url: string;
|
||||
type: "local" | "network" | "tunnel";
|
||||
}
|
||||
interface Listener {
|
||||
url: string;
|
||||
address: AddressInfo;
|
||||
server: Server | Server$1;
|
||||
https: false | Certificate;
|
||||
close: () => Promise<void>;
|
||||
open: () => Promise<void>;
|
||||
showURL: (options?: ShowURLOptions) => Promise<void>;
|
||||
getURLs: (options?: GetURLOptions) => Promise<ListenURL[]>;
|
||||
}
|
||||
|
||||
export type { CrossWSOptions as C, GetURLOptions as G, HTTPSOptions as H, ListenOptions as L, ShowURLOptions as S, Listener as a, Certificate as b, ListenURL as c };
|
||||
82
node_modules/listhen/dist/shared/listhen.1c46e31d.d.ts
generated
vendored
Normal file
82
node_modules/listhen/dist/shared/listhen.1c46e31d.d.ts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { IncomingMessage, Server } from 'node:http';
|
||||
import { Server as Server$1 } from 'node:https';
|
||||
import { AddressInfo } from 'node:net';
|
||||
import { GetPortInput } from 'get-port-please';
|
||||
import { NodeOptions } from 'crossws/adapters/node';
|
||||
|
||||
type CrossWSOptions = NodeOptions;
|
||||
interface Certificate {
|
||||
key: string;
|
||||
cert: string;
|
||||
passphrase?: string;
|
||||
}
|
||||
interface HTTPSOptions {
|
||||
cert?: string;
|
||||
key?: string;
|
||||
pfx?: string;
|
||||
passphrase?: string;
|
||||
validityDays?: number;
|
||||
domains?: string[];
|
||||
}
|
||||
interface ListenOptions {
|
||||
name: string;
|
||||
port: GetPortInput;
|
||||
hostname: string;
|
||||
showURL: boolean;
|
||||
baseURL: string;
|
||||
open: boolean;
|
||||
https: boolean | HTTPSOptions;
|
||||
clipboard: boolean;
|
||||
isTest: boolean;
|
||||
isProd: boolean;
|
||||
autoClose: boolean;
|
||||
_entry?: string;
|
||||
/**
|
||||
* Used as main public url to display
|
||||
* @default The first public IPV4 address listening to
|
||||
*/
|
||||
publicURL?: string;
|
||||
/**
|
||||
* Print QR Code for public IPv4 address
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
qr?: boolean;
|
||||
/**
|
||||
* When enabled, listhen tries to listen to all network interfaces
|
||||
*
|
||||
* @default `false` for development and `true` for production
|
||||
*/
|
||||
public: boolean;
|
||||
/**
|
||||
* Open a tunnel using https://github.com/unjs/untun
|
||||
*/
|
||||
tunnel?: boolean;
|
||||
/**
|
||||
* WebSocket Upgrade Handler
|
||||
*
|
||||
* Input can be an upgrade handler or CrossWS options
|
||||
*
|
||||
* @experimental CrossWS usage is subject to change
|
||||
* @see https://github.com/unjs/crossws
|
||||
*/
|
||||
ws?: boolean | CrossWSOptions | ((req: IncomingMessage, head: Buffer) => void);
|
||||
}
|
||||
type GetURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "publicURL">;
|
||||
type ShowURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "name" | "publicURL" | "qr">;
|
||||
interface ListenURL {
|
||||
url: string;
|
||||
type: "local" | "network" | "tunnel";
|
||||
}
|
||||
interface Listener {
|
||||
url: string;
|
||||
address: AddressInfo;
|
||||
server: Server | Server$1;
|
||||
https: false | Certificate;
|
||||
close: () => Promise<void>;
|
||||
open: () => Promise<void>;
|
||||
showURL: (options?: ShowURLOptions) => Promise<void>;
|
||||
getURLs: (options?: GetURLOptions) => Promise<ListenURL[]>;
|
||||
}
|
||||
|
||||
export type { CrossWSOptions as C, GetURLOptions as G, HTTPSOptions as H, ListenOptions as L, ShowURLOptions as S, Listener as a, Certificate as b, ListenURL as c };
|
||||
Reference in New Issue
Block a user