usage-board 2.1.0 → 2.1.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.
- package/dist/index.mjs +796 -0
- package/dist/public/_nuxt/4bxbFgue.js +260 -0
- package/dist/public/_nuxt/BFuazmgM.js +1 -0
- package/dist/public/_nuxt/BT5lZ84X.js +1 -0
- package/dist/public/_nuxt/BWrHX8SV.js +21 -0
- package/dist/public/_nuxt/Bhg6RTpr.js +25 -0
- package/dist/public/_nuxt/CBNzCW3N.js +9 -0
- package/dist/public/_nuxt/CJwUiTrM.js +1 -0
- package/dist/public/_nuxt/DJtZPkAh.js +1 -0
- package/dist/public/_nuxt/DhnbCV8M.js +1 -0
- package/dist/public/_nuxt/Rw8uLrAX.js +105 -0
- package/dist/public/_nuxt/builds/latest.json +1 -0
- package/dist/public/_nuxt/builds/meta/8e0230d2-a165-4dfa-b759-5387bcb88e4e.json +1 -0
- package/dist/public/_nuxt/entry.r-q4oQC0.css +1 -0
- package/dist/public/_nuxt/error-404.B0EXnOcv.css +1 -0
- package/dist/public/_nuxt/error-500.CnSNZoEG.css +1 -0
- package/dist/public/_nuxt/uC637M1z.js +119 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/logo.svg +4 -0
- package/dist/public/robots.txt +2 -0
- package/dist/server/chunks/_/error-500.mjs +32 -0
- package/dist/server/chunks/_/index.min.mjs +348 -0
- package/dist/server/chunks/_/prompt.mjs +279 -0
- package/dist/server/chunks/_/shared.cjs.prod.mjs +609 -0
- package/dist/server/chunks/build/client.precomputed.mjs +3 -0
- package/dist/server/chunks/nitro/nitro.mjs +7981 -0
- package/dist/server/chunks/routes/api/payload.json.mjs +642 -0
- package/dist/server/chunks/routes/renderer.mjs +39567 -0
- package/dist/server/chunks/routes/ws.mjs +1063 -0
- package/dist/server/chunks/virtual/_virtual_spa-template.mjs +3 -0
- package/dist/server/index.mjs +14 -0
- package/package.json +2 -2
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import path, { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import cac from "cac";
|
|
5
|
+
import { createServer as createServer$1 } from "node:net";
|
|
6
|
+
import os, { networkInterfaces } from "node:os";
|
|
7
|
+
import fs, { constants } from "node:fs/promises";
|
|
8
|
+
import process$1 from "node:process";
|
|
9
|
+
import childProcess, { execFile } from "node:child_process";
|
|
10
|
+
import { promisify } from "node:util";
|
|
11
|
+
import fs$1 from "node:fs";
|
|
12
|
+
import { Buffer } from "node:buffer";
|
|
13
|
+
//#region node_modules/.pnpm/get-port-please@3.2.0/node_modules/get-port-please/dist/index.mjs
|
|
14
|
+
const unsafePorts = /* @__PURE__ */ new Set([
|
|
15
|
+
1,
|
|
16
|
+
7,
|
|
17
|
+
9,
|
|
18
|
+
11,
|
|
19
|
+
13,
|
|
20
|
+
15,
|
|
21
|
+
17,
|
|
22
|
+
19,
|
|
23
|
+
20,
|
|
24
|
+
21,
|
|
25
|
+
22,
|
|
26
|
+
23,
|
|
27
|
+
25,
|
|
28
|
+
37,
|
|
29
|
+
42,
|
|
30
|
+
43,
|
|
31
|
+
53,
|
|
32
|
+
69,
|
|
33
|
+
77,
|
|
34
|
+
79,
|
|
35
|
+
87,
|
|
36
|
+
95,
|
|
37
|
+
101,
|
|
38
|
+
102,
|
|
39
|
+
103,
|
|
40
|
+
104,
|
|
41
|
+
109,
|
|
42
|
+
110,
|
|
43
|
+
111,
|
|
44
|
+
113,
|
|
45
|
+
115,
|
|
46
|
+
117,
|
|
47
|
+
119,
|
|
48
|
+
123,
|
|
49
|
+
135,
|
|
50
|
+
137,
|
|
51
|
+
139,
|
|
52
|
+
143,
|
|
53
|
+
161,
|
|
54
|
+
179,
|
|
55
|
+
389,
|
|
56
|
+
427,
|
|
57
|
+
465,
|
|
58
|
+
512,
|
|
59
|
+
513,
|
|
60
|
+
514,
|
|
61
|
+
515,
|
|
62
|
+
526,
|
|
63
|
+
530,
|
|
64
|
+
531,
|
|
65
|
+
532,
|
|
66
|
+
540,
|
|
67
|
+
548,
|
|
68
|
+
554,
|
|
69
|
+
556,
|
|
70
|
+
563,
|
|
71
|
+
587,
|
|
72
|
+
601,
|
|
73
|
+
636,
|
|
74
|
+
989,
|
|
75
|
+
990,
|
|
76
|
+
993,
|
|
77
|
+
995,
|
|
78
|
+
1719,
|
|
79
|
+
1720,
|
|
80
|
+
1723,
|
|
81
|
+
2049,
|
|
82
|
+
3659,
|
|
83
|
+
4045,
|
|
84
|
+
5060,
|
|
85
|
+
5061,
|
|
86
|
+
6e3,
|
|
87
|
+
6566,
|
|
88
|
+
6665,
|
|
89
|
+
6666,
|
|
90
|
+
6667,
|
|
91
|
+
6668,
|
|
92
|
+
6669,
|
|
93
|
+
6697,
|
|
94
|
+
10080
|
|
95
|
+
]);
|
|
96
|
+
function isUnsafePort(port) {
|
|
97
|
+
return unsafePorts.has(port);
|
|
98
|
+
}
|
|
99
|
+
function isSafePort(port) {
|
|
100
|
+
return !isUnsafePort(port);
|
|
101
|
+
}
|
|
102
|
+
var GetPortError = class extends Error {
|
|
103
|
+
constructor(message, opts) {
|
|
104
|
+
super(message, opts);
|
|
105
|
+
this.message = message;
|
|
106
|
+
}
|
|
107
|
+
name = "GetPortError";
|
|
108
|
+
};
|
|
109
|
+
function _log(verbose, message) {
|
|
110
|
+
if (verbose) console.log(`[get-port] ${message}`);
|
|
111
|
+
}
|
|
112
|
+
function _generateRange(from, to) {
|
|
113
|
+
if (to < from) return [];
|
|
114
|
+
const r = [];
|
|
115
|
+
for (let index = from; index <= to; index++) r.push(index);
|
|
116
|
+
return r;
|
|
117
|
+
}
|
|
118
|
+
function _tryPort(port, host) {
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
const server = createServer$1();
|
|
121
|
+
server.unref();
|
|
122
|
+
server.on("error", () => {
|
|
123
|
+
resolve(false);
|
|
124
|
+
});
|
|
125
|
+
server.listen({
|
|
126
|
+
port,
|
|
127
|
+
host
|
|
128
|
+
}, () => {
|
|
129
|
+
const { port: port2 } = server.address();
|
|
130
|
+
server.close(() => {
|
|
131
|
+
resolve(isSafePort(port2) && port2);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function _getLocalHosts(additional) {
|
|
137
|
+
const hosts = new Set(additional);
|
|
138
|
+
for (const _interface of Object.values(networkInterfaces())) for (const config of _interface || []) if (config.address && !config.internal && !config.address.startsWith("fe80::") && !config.address.startsWith("169.254")) hosts.add(config.address);
|
|
139
|
+
return [...hosts];
|
|
140
|
+
}
|
|
141
|
+
async function _findPort(ports, host) {
|
|
142
|
+
for (const port of ports) {
|
|
143
|
+
const r = await _tryPort(port, host);
|
|
144
|
+
if (r) return r;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function _fmtOnHost(hostname) {
|
|
148
|
+
return hostname ? `on host ${JSON.stringify(hostname)}` : "on any host";
|
|
149
|
+
}
|
|
150
|
+
const HOSTNAME_RE = /^(?!-)[\d.:A-Za-z-]{1,63}(?<!-)$/;
|
|
151
|
+
function _validateHostname(hostname, _public, verbose) {
|
|
152
|
+
if (hostname && !HOSTNAME_RE.test(hostname)) {
|
|
153
|
+
const fallbackHost = _public ? "0.0.0.0" : "127.0.0.1";
|
|
154
|
+
_log(verbose, `Invalid hostname: ${JSON.stringify(hostname)}. Using ${JSON.stringify(fallbackHost)} as fallback.`);
|
|
155
|
+
return fallbackHost;
|
|
156
|
+
}
|
|
157
|
+
return hostname;
|
|
158
|
+
}
|
|
159
|
+
async function getPort(_userOptions = {}) {
|
|
160
|
+
if (typeof _userOptions === "number" || typeof _userOptions === "string") _userOptions = { port: Number.parseInt(_userOptions + "") || 0 };
|
|
161
|
+
const _port = Number(_userOptions.port ?? process.env.PORT);
|
|
162
|
+
const _userSpecifiedAnyPort = Boolean(_userOptions.port || _userOptions.ports?.length || _userOptions.portRange?.length);
|
|
163
|
+
const options = {
|
|
164
|
+
random: _port === 0,
|
|
165
|
+
ports: [],
|
|
166
|
+
portRange: [],
|
|
167
|
+
alternativePortRange: _userSpecifiedAnyPort ? [] : [3e3, 3100],
|
|
168
|
+
verbose: false,
|
|
169
|
+
..._userOptions,
|
|
170
|
+
port: _port,
|
|
171
|
+
host: _validateHostname(_userOptions.host ?? process.env.HOST, _userOptions.public, _userOptions.verbose)
|
|
172
|
+
};
|
|
173
|
+
if (options.random && !_userSpecifiedAnyPort) return getRandomPort(options.host);
|
|
174
|
+
const portsToCheck = [
|
|
175
|
+
options.port,
|
|
176
|
+
...options.ports,
|
|
177
|
+
..._generateRange(...options.portRange)
|
|
178
|
+
].filter((port) => {
|
|
179
|
+
if (!port) return false;
|
|
180
|
+
if (!isSafePort(port)) {
|
|
181
|
+
_log(options.verbose, `Ignoring unsafe port: ${port}`);
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
});
|
|
186
|
+
if (portsToCheck.length === 0) portsToCheck.push(3e3);
|
|
187
|
+
let availablePort = await _findPort(portsToCheck, options.host);
|
|
188
|
+
if (!availablePort && options.alternativePortRange.length > 0) {
|
|
189
|
+
availablePort = await _findPort(_generateRange(...options.alternativePortRange), options.host);
|
|
190
|
+
if (portsToCheck.length > 0) {
|
|
191
|
+
let message = `Unable to find an available port (tried ${portsToCheck.join("-")} ${_fmtOnHost(options.host)}).`;
|
|
192
|
+
if (availablePort) message += ` Using alternative port ${availablePort}.`;
|
|
193
|
+
_log(options.verbose, message);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (!availablePort && _userOptions.random !== false) {
|
|
197
|
+
availablePort = await getRandomPort(options.host);
|
|
198
|
+
if (availablePort) _log(options.verbose, `Using random port ${availablePort}`);
|
|
199
|
+
}
|
|
200
|
+
if (!availablePort) {
|
|
201
|
+
const triedRanges = [
|
|
202
|
+
options.port,
|
|
203
|
+
options.portRange.join("-"),
|
|
204
|
+
options.alternativePortRange.join("-")
|
|
205
|
+
].filter(Boolean).join(", ");
|
|
206
|
+
throw new GetPortError(`Unable to find an available port ${_fmtOnHost(options.host)} (tried ${triedRanges})`);
|
|
207
|
+
}
|
|
208
|
+
return availablePort;
|
|
209
|
+
}
|
|
210
|
+
async function getRandomPort(host) {
|
|
211
|
+
const port = await checkPort(0, host);
|
|
212
|
+
if (port === false) throw new GetPortError(`Unable to find a random port ${_fmtOnHost(host)}`);
|
|
213
|
+
return port;
|
|
214
|
+
}
|
|
215
|
+
async function checkPort(port, host = process.env.HOST, verbose) {
|
|
216
|
+
if (!host) host = _getLocalHosts([void 0, "0.0.0.0"]);
|
|
217
|
+
if (!Array.isArray(host)) return _tryPort(port, host);
|
|
218
|
+
for (const _host of host) {
|
|
219
|
+
const _port = await _tryPort(port, _host);
|
|
220
|
+
if (_port === false) {
|
|
221
|
+
if (port < 1024 && verbose) _log(verbose, `Unable to listen to the privileged port ${port} ${_fmtOnHost(_host)}`);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
if (port === 0 && _port !== 0) port = _port;
|
|
225
|
+
}
|
|
226
|
+
return port;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
230
|
+
let isDockerCached;
|
|
231
|
+
function hasDockerEnv() {
|
|
232
|
+
try {
|
|
233
|
+
fs$1.statSync("/.dockerenv");
|
|
234
|
+
return true;
|
|
235
|
+
} catch {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function hasDockerCGroup() {
|
|
240
|
+
try {
|
|
241
|
+
return fs$1.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
242
|
+
} catch {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function isDocker() {
|
|
247
|
+
if (isDockerCached === void 0) isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
248
|
+
return isDockerCached;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
252
|
+
let cachedResult;
|
|
253
|
+
const hasContainerEnv = () => {
|
|
254
|
+
try {
|
|
255
|
+
fs$1.statSync("/run/.containerenv");
|
|
256
|
+
return true;
|
|
257
|
+
} catch {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
function isInsideContainer() {
|
|
262
|
+
if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
|
|
263
|
+
return cachedResult;
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region node_modules/.pnpm/is-wsl@3.1.1/node_modules/is-wsl/index.js
|
|
267
|
+
const isWsl = () => {
|
|
268
|
+
if (process$1.platform !== "linux") return false;
|
|
269
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
270
|
+
if (isInsideContainer()) return false;
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
try {
|
|
274
|
+
if (fs$1.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) return !isInsideContainer();
|
|
275
|
+
} catch {}
|
|
276
|
+
if (fs$1.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs$1.existsSync("/run/WSL")) return !isInsideContainer();
|
|
277
|
+
return false;
|
|
278
|
+
};
|
|
279
|
+
var is_wsl_default = process$1.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
282
|
+
const execFile$2 = promisify(childProcess.execFile);
|
|
283
|
+
const powerShellPath$1 = () => `${process$1.env.SYSTEMROOT || process$1.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
284
|
+
const executePowerShell = async (command, options = {}) => {
|
|
285
|
+
const { powerShellPath: psPath, ...execFileOptions } = options;
|
|
286
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
287
|
+
return execFile$2(psPath ?? powerShellPath$1(), [...executePowerShell.argumentsPrefix, encodedCommand], {
|
|
288
|
+
encoding: "utf8",
|
|
289
|
+
...execFileOptions
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
executePowerShell.argumentsPrefix = [
|
|
293
|
+
"-NoProfile",
|
|
294
|
+
"-NonInteractive",
|
|
295
|
+
"-ExecutionPolicy",
|
|
296
|
+
"Bypass",
|
|
297
|
+
"-EncodedCommand"
|
|
298
|
+
];
|
|
299
|
+
executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
|
|
300
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
|
|
303
|
+
function parseMountPointFromConfig(content) {
|
|
304
|
+
for (const line of content.split("\n")) {
|
|
305
|
+
if (/^\s*#/.test(line)) continue;
|
|
306
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
307
|
+
if (!match) continue;
|
|
308
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
313
|
+
const execFile$1 = promisify(childProcess.execFile);
|
|
314
|
+
const wslDrivesMountPoint = (() => {
|
|
315
|
+
const defaultMountPoint = "/mnt/";
|
|
316
|
+
let mountPoint;
|
|
317
|
+
return async function() {
|
|
318
|
+
if (mountPoint) return mountPoint;
|
|
319
|
+
const configFilePath = "/etc/wsl.conf";
|
|
320
|
+
let isConfigFileExists = false;
|
|
321
|
+
try {
|
|
322
|
+
await fs.access(configFilePath, constants.F_OK);
|
|
323
|
+
isConfigFileExists = true;
|
|
324
|
+
} catch {}
|
|
325
|
+
if (!isConfigFileExists) return defaultMountPoint;
|
|
326
|
+
const parsedMountPoint = parseMountPointFromConfig(await fs.readFile(configFilePath, { encoding: "utf8" }));
|
|
327
|
+
if (parsedMountPoint === void 0) return defaultMountPoint;
|
|
328
|
+
mountPoint = parsedMountPoint;
|
|
329
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
330
|
+
return mountPoint;
|
|
331
|
+
};
|
|
332
|
+
})();
|
|
333
|
+
const powerShellPathFromWsl = async () => {
|
|
334
|
+
return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
335
|
+
};
|
|
336
|
+
const powerShellPath = is_wsl_default ? powerShellPathFromWsl : powerShellPath$1;
|
|
337
|
+
let canAccessPowerShellPromise;
|
|
338
|
+
const canAccessPowerShell = async () => {
|
|
339
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
340
|
+
try {
|
|
341
|
+
const psPath = await powerShellPath();
|
|
342
|
+
await fs.access(psPath, constants.X_OK);
|
|
343
|
+
return true;
|
|
344
|
+
} catch {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
})();
|
|
348
|
+
return canAccessPowerShellPromise;
|
|
349
|
+
};
|
|
350
|
+
const wslDefaultBrowser = async () => {
|
|
351
|
+
const psPath = await powerShellPath();
|
|
352
|
+
const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
|
|
353
|
+
return stdout.trim();
|
|
354
|
+
};
|
|
355
|
+
const convertWslPathToWindows = async (path) => {
|
|
356
|
+
if (/^[a-z]+:\/\//i.test(path)) return path;
|
|
357
|
+
try {
|
|
358
|
+
const { stdout } = await execFile$1("wslpath", ["-aw", path], { encoding: "utf8" });
|
|
359
|
+
return stdout.trim();
|
|
360
|
+
} catch {
|
|
361
|
+
return path;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
366
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
367
|
+
const define = (value) => Object.defineProperty(object, propertyName, {
|
|
368
|
+
value,
|
|
369
|
+
enumerable: true,
|
|
370
|
+
writable: true
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(object, propertyName, {
|
|
373
|
+
configurable: true,
|
|
374
|
+
enumerable: true,
|
|
375
|
+
get() {
|
|
376
|
+
const result = valueGetter();
|
|
377
|
+
define(result);
|
|
378
|
+
return result;
|
|
379
|
+
},
|
|
380
|
+
set(value) {
|
|
381
|
+
define(value);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
return object;
|
|
385
|
+
}
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
388
|
+
const execFileAsync$3 = promisify(execFile);
|
|
389
|
+
async function defaultBrowserId() {
|
|
390
|
+
if (process$1.platform !== "darwin") throw new Error("macOS only");
|
|
391
|
+
const { stdout } = await execFileAsync$3("defaults", [
|
|
392
|
+
"read",
|
|
393
|
+
"com.apple.LaunchServices/com.apple.launchservices.secure",
|
|
394
|
+
"LSHandlers"
|
|
395
|
+
]);
|
|
396
|
+
const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout)?.groups.id ?? "com.apple.Safari";
|
|
397
|
+
if (browserId === "com.apple.safari") return "com.apple.Safari";
|
|
398
|
+
return browserId;
|
|
399
|
+
}
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
402
|
+
const execFileAsync$2 = promisify(execFile);
|
|
403
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
404
|
+
if (process$1.platform !== "darwin") throw new Error("macOS only");
|
|
405
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
406
|
+
const execOptions = {};
|
|
407
|
+
if (signal) execOptions.signal = signal;
|
|
408
|
+
const { stdout } = await execFileAsync$2("osascript", [
|
|
409
|
+
"-e",
|
|
410
|
+
script,
|
|
411
|
+
outputArguments
|
|
412
|
+
], execOptions);
|
|
413
|
+
return stdout.trim();
|
|
414
|
+
}
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
417
|
+
async function bundleName(bundleId) {
|
|
418
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
422
|
+
const execFileAsync$1 = promisify(execFile);
|
|
423
|
+
const windowsBrowserProgIds = {
|
|
424
|
+
MSEdgeHTM: {
|
|
425
|
+
name: "Edge",
|
|
426
|
+
id: "com.microsoft.edge"
|
|
427
|
+
},
|
|
428
|
+
MSEdgeBHTML: {
|
|
429
|
+
name: "Edge Beta",
|
|
430
|
+
id: "com.microsoft.edge.beta"
|
|
431
|
+
},
|
|
432
|
+
MSEdgeDHTML: {
|
|
433
|
+
name: "Edge Dev",
|
|
434
|
+
id: "com.microsoft.edge.dev"
|
|
435
|
+
},
|
|
436
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
|
|
437
|
+
name: "Edge",
|
|
438
|
+
id: "com.microsoft.edge.old"
|
|
439
|
+
},
|
|
440
|
+
ChromeHTML: {
|
|
441
|
+
name: "Chrome",
|
|
442
|
+
id: "com.google.chrome"
|
|
443
|
+
},
|
|
444
|
+
ChromeBHTML: {
|
|
445
|
+
name: "Chrome Beta",
|
|
446
|
+
id: "com.google.chrome.beta"
|
|
447
|
+
},
|
|
448
|
+
ChromeDHTML: {
|
|
449
|
+
name: "Chrome Dev",
|
|
450
|
+
id: "com.google.chrome.dev"
|
|
451
|
+
},
|
|
452
|
+
ChromiumHTM: {
|
|
453
|
+
name: "Chromium",
|
|
454
|
+
id: "org.chromium.Chromium"
|
|
455
|
+
},
|
|
456
|
+
BraveHTML: {
|
|
457
|
+
name: "Brave",
|
|
458
|
+
id: "com.brave.Browser"
|
|
459
|
+
},
|
|
460
|
+
BraveBHTML: {
|
|
461
|
+
name: "Brave Beta",
|
|
462
|
+
id: "com.brave.Browser.beta"
|
|
463
|
+
},
|
|
464
|
+
BraveDHTML: {
|
|
465
|
+
name: "Brave Dev",
|
|
466
|
+
id: "com.brave.Browser.dev"
|
|
467
|
+
},
|
|
468
|
+
BraveSSHTM: {
|
|
469
|
+
name: "Brave Nightly",
|
|
470
|
+
id: "com.brave.Browser.nightly"
|
|
471
|
+
},
|
|
472
|
+
FirefoxURL: {
|
|
473
|
+
name: "Firefox",
|
|
474
|
+
id: "org.mozilla.firefox"
|
|
475
|
+
},
|
|
476
|
+
OperaStable: {
|
|
477
|
+
name: "Opera",
|
|
478
|
+
id: "com.operasoftware.Opera"
|
|
479
|
+
},
|
|
480
|
+
VivaldiHTM: {
|
|
481
|
+
name: "Vivaldi",
|
|
482
|
+
id: "com.vivaldi.Vivaldi"
|
|
483
|
+
},
|
|
484
|
+
"IE.HTTP": {
|
|
485
|
+
name: "Internet Explorer",
|
|
486
|
+
id: "com.microsoft.ie"
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
490
|
+
var UnknownBrowserError = class extends Error {};
|
|
491
|
+
async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
|
|
492
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
493
|
+
"QUERY",
|
|
494
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
495
|
+
"/v",
|
|
496
|
+
"ProgId"
|
|
497
|
+
]);
|
|
498
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
499
|
+
if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
500
|
+
const { id } = match.groups;
|
|
501
|
+
const dotIndex = id.lastIndexOf(".");
|
|
502
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
503
|
+
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
504
|
+
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
505
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
|
|
506
|
+
name: id,
|
|
507
|
+
id
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
512
|
+
const execFileAsync = promisify(execFile);
|
|
513
|
+
const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
514
|
+
async function defaultBrowser() {
|
|
515
|
+
if (process$1.platform === "darwin") {
|
|
516
|
+
const id = await defaultBrowserId();
|
|
517
|
+
return {
|
|
518
|
+
name: await bundleName(id),
|
|
519
|
+
id
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
if (process$1.platform === "linux") {
|
|
523
|
+
const { stdout } = await execFileAsync("xdg-mime", [
|
|
524
|
+
"query",
|
|
525
|
+
"default",
|
|
526
|
+
"x-scheme-handler/http"
|
|
527
|
+
]);
|
|
528
|
+
const id = stdout.trim();
|
|
529
|
+
return {
|
|
530
|
+
name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
|
|
531
|
+
id
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
if (process$1.platform === "win32") return defaultBrowser$1();
|
|
535
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
536
|
+
}
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
539
|
+
const isInSsh = Boolean(process$1.env.SSH_CONNECTION || process$1.env.SSH_CLIENT || process$1.env.SSH_TTY);
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
542
|
+
const fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
543
|
+
const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
|
|
544
|
+
const localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
545
|
+
const { platform, arch } = process$1;
|
|
546
|
+
const tryEachApp = async (apps, opener) => {
|
|
547
|
+
if (apps.length === 0) return;
|
|
548
|
+
const errors = [];
|
|
549
|
+
for (const app of apps) try {
|
|
550
|
+
return await opener(app);
|
|
551
|
+
} catch (error) {
|
|
552
|
+
errors.push(error);
|
|
553
|
+
}
|
|
554
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
555
|
+
};
|
|
556
|
+
const baseOpen = async (options) => {
|
|
557
|
+
options = {
|
|
558
|
+
wait: false,
|
|
559
|
+
background: false,
|
|
560
|
+
newInstance: false,
|
|
561
|
+
allowNonzeroExitCode: false,
|
|
562
|
+
...options
|
|
563
|
+
};
|
|
564
|
+
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
565
|
+
delete options[fallbackAttemptSymbol];
|
|
566
|
+
if (Array.isArray(options.app)) return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
567
|
+
...options,
|
|
568
|
+
app: singleApp,
|
|
569
|
+
[fallbackAttemptSymbol]: true
|
|
570
|
+
}));
|
|
571
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
572
|
+
appArguments = [...appArguments];
|
|
573
|
+
if (Array.isArray(app)) return tryEachApp(app, (appName) => baseOpen({
|
|
574
|
+
...options,
|
|
575
|
+
app: {
|
|
576
|
+
name: appName,
|
|
577
|
+
arguments: appArguments
|
|
578
|
+
},
|
|
579
|
+
[fallbackAttemptSymbol]: true
|
|
580
|
+
}));
|
|
581
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
582
|
+
const ids = {
|
|
583
|
+
"com.google.chrome": "chrome",
|
|
584
|
+
"google-chrome.desktop": "chrome",
|
|
585
|
+
"com.brave.browser": "brave",
|
|
586
|
+
"org.mozilla.firefox": "firefox",
|
|
587
|
+
"firefox.desktop": "firefox",
|
|
588
|
+
"com.microsoft.msedge": "edge",
|
|
589
|
+
"com.microsoft.edge": "edge",
|
|
590
|
+
"com.microsoft.edgemac": "edge",
|
|
591
|
+
"microsoft-edge.desktop": "edge",
|
|
592
|
+
"com.apple.safari": "safari"
|
|
593
|
+
};
|
|
594
|
+
const flags = {
|
|
595
|
+
chrome: "--incognito",
|
|
596
|
+
brave: "--incognito",
|
|
597
|
+
firefox: "--private-window",
|
|
598
|
+
edge: "--inPrivate"
|
|
599
|
+
};
|
|
600
|
+
let browser;
|
|
601
|
+
if (is_wsl_default) {
|
|
602
|
+
const progId = await wslDefaultBrowser();
|
|
603
|
+
browser = _windowsBrowserProgIdMap.get(progId) ?? {};
|
|
604
|
+
} else browser = await defaultBrowser();
|
|
605
|
+
if (browser.id in ids) {
|
|
606
|
+
const browserName = ids[browser.id.toLowerCase()];
|
|
607
|
+
if (app === "browserPrivate") {
|
|
608
|
+
if (browserName === "safari") throw new Error("Safari doesn't support opening in private mode via command line");
|
|
609
|
+
appArguments.push(flags[browserName]);
|
|
610
|
+
}
|
|
611
|
+
return baseOpen({
|
|
612
|
+
...options,
|
|
613
|
+
app: {
|
|
614
|
+
name: apps[browserName],
|
|
615
|
+
arguments: appArguments
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
620
|
+
}
|
|
621
|
+
let command;
|
|
622
|
+
const cliArguments = [];
|
|
623
|
+
const childProcessOptions = {};
|
|
624
|
+
let shouldUseWindowsInWsl = false;
|
|
625
|
+
if (is_wsl_default && !isInsideContainer() && !isInSsh && !app) shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
626
|
+
if (platform === "darwin") {
|
|
627
|
+
command = "open";
|
|
628
|
+
if (options.wait) cliArguments.push("--wait-apps");
|
|
629
|
+
if (options.background) cliArguments.push("--background");
|
|
630
|
+
if (options.newInstance) cliArguments.push("--new");
|
|
631
|
+
if (app) cliArguments.push("-a", app);
|
|
632
|
+
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
633
|
+
command = await powerShellPath();
|
|
634
|
+
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
635
|
+
if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
|
|
636
|
+
if (is_wsl_default && options.target) options.target = await convertWslPathToWindows(options.target);
|
|
637
|
+
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
638
|
+
if (options.wait) encodedArguments.push("-Wait");
|
|
639
|
+
if (app) {
|
|
640
|
+
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
641
|
+
if (options.target) appArguments.push(options.target);
|
|
642
|
+
} else if (options.target) encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
643
|
+
if (appArguments.length > 0) {
|
|
644
|
+
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
645
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
646
|
+
}
|
|
647
|
+
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
648
|
+
if (!options.wait) childProcessOptions.stdio = "ignore";
|
|
649
|
+
} else {
|
|
650
|
+
if (app) command = app;
|
|
651
|
+
else {
|
|
652
|
+
const isBundled = !__dirname || __dirname === "/";
|
|
653
|
+
let exeLocalXdgOpen = false;
|
|
654
|
+
try {
|
|
655
|
+
await fs.access(localXdgOpenPath, constants.X_OK);
|
|
656
|
+
exeLocalXdgOpen = true;
|
|
657
|
+
} catch {}
|
|
658
|
+
command = process$1.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
|
|
659
|
+
}
|
|
660
|
+
if (appArguments.length > 0) cliArguments.push(...appArguments);
|
|
661
|
+
if (!options.wait) {
|
|
662
|
+
childProcessOptions.stdio = "ignore";
|
|
663
|
+
childProcessOptions.detached = true;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (platform === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
|
|
667
|
+
if (options.target) cliArguments.push(options.target);
|
|
668
|
+
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
669
|
+
if (options.wait) return new Promise((resolve, reject) => {
|
|
670
|
+
subprocess.once("error", reject);
|
|
671
|
+
subprocess.once("close", (exitCode) => {
|
|
672
|
+
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
673
|
+
reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
resolve(subprocess);
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
if (isFallbackAttempt) return new Promise((resolve, reject) => {
|
|
680
|
+
subprocess.once("error", reject);
|
|
681
|
+
subprocess.once("spawn", () => {
|
|
682
|
+
subprocess.once("close", (exitCode) => {
|
|
683
|
+
subprocess.off("error", reject);
|
|
684
|
+
if (exitCode !== 0) {
|
|
685
|
+
reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
subprocess.unref();
|
|
689
|
+
resolve(subprocess);
|
|
690
|
+
});
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
subprocess.unref();
|
|
694
|
+
return new Promise((resolve, reject) => {
|
|
695
|
+
subprocess.once("error", reject);
|
|
696
|
+
subprocess.once("spawn", () => {
|
|
697
|
+
subprocess.off("error", reject);
|
|
698
|
+
resolve(subprocess);
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
};
|
|
702
|
+
const open = (target, options) => {
|
|
703
|
+
if (typeof target !== "string") throw new TypeError("Expected a `target`");
|
|
704
|
+
return baseOpen({
|
|
705
|
+
...options,
|
|
706
|
+
target
|
|
707
|
+
});
|
|
708
|
+
};
|
|
709
|
+
function detectArchBinary(binary) {
|
|
710
|
+
if (typeof binary === "string" || Array.isArray(binary)) return binary;
|
|
711
|
+
const { [arch]: archBinary } = binary;
|
|
712
|
+
if (!archBinary) throw new Error(`${arch} is not supported`);
|
|
713
|
+
return archBinary;
|
|
714
|
+
}
|
|
715
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
716
|
+
if (wsl && is_wsl_default) return detectArchBinary(wsl);
|
|
717
|
+
if (!platformBinary) throw new Error(`${platform} is not supported`);
|
|
718
|
+
return detectArchBinary(platformBinary);
|
|
719
|
+
}
|
|
720
|
+
const apps = {
|
|
721
|
+
browser: "browser",
|
|
722
|
+
browserPrivate: "browserPrivate"
|
|
723
|
+
};
|
|
724
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
725
|
+
darwin: "google chrome",
|
|
726
|
+
win32: "chrome",
|
|
727
|
+
linux: [
|
|
728
|
+
"google-chrome",
|
|
729
|
+
"google-chrome-stable",
|
|
730
|
+
"chromium",
|
|
731
|
+
"chromium-browser"
|
|
732
|
+
]
|
|
733
|
+
}, { wsl: {
|
|
734
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
735
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
736
|
+
} }));
|
|
737
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
738
|
+
darwin: "brave browser",
|
|
739
|
+
win32: "brave",
|
|
740
|
+
linux: ["brave-browser", "brave"]
|
|
741
|
+
}, { wsl: {
|
|
742
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
743
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
744
|
+
} }));
|
|
745
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
746
|
+
darwin: "firefox",
|
|
747
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
748
|
+
linux: "firefox"
|
|
749
|
+
}, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
|
|
750
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
751
|
+
darwin: "microsoft edge",
|
|
752
|
+
win32: "msedge",
|
|
753
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
754
|
+
}, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
|
|
755
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" }));
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region package.json
|
|
758
|
+
var name = "usage-board";
|
|
759
|
+
var version = "2.1.1";
|
|
760
|
+
//#endregion
|
|
761
|
+
//#region src/index.ts
|
|
762
|
+
const cli = cac(name);
|
|
763
|
+
async function loadNitroEntrypoint(outputDir) {
|
|
764
|
+
const mod = await import(resolve(outputDir, "server/index.mjs"));
|
|
765
|
+
return {
|
|
766
|
+
listener: mod.listener ?? mod.middleware ?? mod.handler ?? mod.default,
|
|
767
|
+
websocket: mod.websocket
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
cli.command("", "Start tokens usage analysis").option("--host <host>", "Host", { default: "127.0.0.1" }).option("--port <port>", "Port", { default: 7777 }).option("--open", "Open browser", { default: true }).action(async (option) => {
|
|
771
|
+
const port = await getPort({
|
|
772
|
+
port: option.port,
|
|
773
|
+
portRange: [7777, 9e3]
|
|
774
|
+
});
|
|
775
|
+
const nitro = await loadNitroEntrypoint(resolve(dirname(fileURLToPath(import.meta.url)), "./"));
|
|
776
|
+
const app = createServer(async (req, res) => {
|
|
777
|
+
await nitro.listener(req, res);
|
|
778
|
+
});
|
|
779
|
+
if (nitro.websocket) {
|
|
780
|
+
const { default: wsAdapter } = await import("crossws/adapters/node");
|
|
781
|
+
const { handleUpgrade } = wsAdapter(nitro.websocket);
|
|
782
|
+
app.on("upgrade", handleUpgrade);
|
|
783
|
+
}
|
|
784
|
+
app.listen(port, option.host, async () => {
|
|
785
|
+
if (option.open) {
|
|
786
|
+
const url = `http://${option.host}:${port}`;
|
|
787
|
+
console.log(`Usage board is running at ${url}`);
|
|
788
|
+
await open(url);
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
});
|
|
792
|
+
cli.help();
|
|
793
|
+
cli.version(version);
|
|
794
|
+
cli.parse();
|
|
795
|
+
//#endregion
|
|
796
|
+
export {};
|