@ganglion/xacpx-relay 0.2.1 → 0.2.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.
package/dist/cli.d.ts CHANGED
@@ -7,9 +7,13 @@ export declare function defaultDbPath(): string;
7
7
  /**
8
8
  * Locates the bundled relay-web dashboard relative to the compiled cli.js.
9
9
  * Returns the path only if `index.html` is present there; otherwise undefined.
10
- * Defensive: returns undefined if process.argv[1] is not set.
10
+ *
11
+ * Resolves against this module's own URL (import.meta.url), NOT process.argv[1]:
12
+ * when invoked via the global `xacpx-relay` bin symlink, argv[1] is the symlink
13
+ * path (…/bin/xacpx-relay), not the real cli.js, so an argv-based path would
14
+ * mis-resolve. The `cliJsPath` param exists only for tests.
11
15
  */
12
- export declare function resolveBundledWebRoot(): string | undefined;
16
+ export declare function resolveBundledWebRoot(cliJsPath?: string): string | undefined;
13
17
  export interface StartOptions {
14
18
  dbPath: string;
15
19
  httpPort: number;
package/dist/cli.js CHANGED
@@ -7,6 +7,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
7
7
  import { existsSync } from "node:fs";
8
8
  import { homedir } from "node:os";
9
9
  import { dirname as dirname2, join, resolve } from "node:path";
10
+ import { fileURLToPath } from "node:url";
10
11
 
11
12
  // packages/relay/src/server.ts
12
13
  import { serve } from "@hono/node-server";
@@ -1042,13 +1043,8 @@ function parseCookie(header) {
1042
1043
  function defaultDbPath() {
1043
1044
  return join(homedir(), ".xacpx-relay", "relay.db");
1044
1045
  }
1045
- function resolveBundledWebRoot() {
1046
- const argv1 = process.argv[1];
1047
- if (!argv1)
1048
- return;
1049
- if (!argv1.endsWith("cli.js"))
1050
- return;
1051
- const here = dirname2(argv1);
1046
+ function resolveBundledWebRoot(cliJsPath = fileURLToPath(import.meta.url)) {
1047
+ const here = dirname2(cliJsPath);
1052
1048
  const embedded = resolve(here, "relay-web");
1053
1049
  if (existsSync(join(embedded, "index.html")))
1054
1050
  return embedded;
@@ -1170,8 +1166,7 @@ async function runRelayCli(args, io) {
1170
1166
  io.print(USAGE);
1171
1167
  return 1;
1172
1168
  }
1173
- var isMain = typeof process !== "undefined" && process.argv[1]?.endsWith("cli.js");
1174
- if (isMain) {
1169
+ if (__require.main == __require.module) {
1175
1170
  runRelayCli(process.argv.slice(2), { print: (line) => console.log(line) }).then((code) => process.exit(code), (error) => {
1176
1171
  console.error(error instanceof Error ? error.message : String(error));
1177
1172
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ganglion/xacpx-relay",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Self-hosted relay hub for xacpx: instance gateway, accounts, and web API.",
5
5
  "license": "MIT",
6
6
  "keywords": ["xacpx", "relay", "hub"],