@syengup/friday-channel-next 0.0.43 → 0.0.44

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.
@@ -1,29 +1,20 @@
1
1
  import { readdirSync } from "node:fs";
2
- import { join, dirname } from "node:path";
3
- import { fileURLToPath } from "node:url";
2
+ import { join } from "node:path";
4
3
  let cache = null;
5
4
  function resolveOpenClawDist() {
6
- // Walk up from the gateway-resolved SDK module to find the dist directory.
7
- // import.meta.resolve is available in Node 20.6+.
8
- try {
9
- const corePath = fileURLToPath(import.meta.resolve("openclaw/plugin-sdk/core"));
10
- return dirname(dirname(corePath)); // dist/plugin-sdk/core.js → dist/
11
- }
12
- catch {
13
- for (const root of [
14
- join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
15
- "/opt/homebrew/lib/node_modules/openclaw/dist",
16
- "/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
17
- "/usr/local/lib/node_modules/openclaw/dist",
18
- ]) {
19
- try {
20
- readdirSync(root);
21
- return root;
22
- }
23
- catch { }
5
+ for (const root of [
6
+ join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
7
+ "/opt/homebrew/lib/node_modules/openclaw/dist",
8
+ "/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
9
+ "/usr/local/lib/node_modules/openclaw/dist",
10
+ ]) {
11
+ try {
12
+ readdirSync(root);
13
+ return root;
24
14
  }
25
- throw new Error("OpenClaw dist directory not found");
15
+ catch { }
26
16
  }
17
+ throw new Error("OpenClaw dist directory not found");
27
18
  }
28
19
  export async function loadNodePairingModule() {
29
20
  if (cache)
@@ -32,9 +23,24 @@ export async function loadNodePairingModule() {
32
23
  const file = readdirSync(dist).find((f) => f.startsWith("node-pairing-") && f.endsWith(".js") && !f.includes("authz"));
33
24
  if (!file)
34
25
  throw new Error("node-pairing module not found in OpenClaw dist");
35
- // ESM import() correctly resolves named exports (listNodePairing, approveNodePairing)
36
- // unlike createRequire which exposes the minified export names (r, t).
37
- cache = await import(join(dist, file));
26
+ // ESM import() returns the minified export names (r, t, …) because the
27
+ // bundled module uses `export { listNodePairing as r, … }`. Resolve the
28
+ // correct functions by Function.name, which preserves the original name.
29
+ const mod = await import(join(dist, file));
30
+ let listNodePairing;
31
+ let approveNodePairing;
32
+ for (const value of Object.values(mod)) {
33
+ if (typeof value === "function") {
34
+ if (value.name === "listNodePairing")
35
+ listNodePairing = value;
36
+ else if (value.name === "approveNodePairing")
37
+ approveNodePairing = value;
38
+ }
39
+ }
40
+ if (!listNodePairing || !approveNodePairing) {
41
+ throw new Error("node-pairing module did not export expected functions");
42
+ }
43
+ cache = { listNodePairing, approveNodePairing };
38
44
  return cache;
39
45
  }
40
46
  /** Vitest-only: inject mock pairing functions. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syengup/friday-channel-next",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "OpenClaw Friday Next Apple channel plugin",
5
5
  "type": "module",
6
6
  "files": [
@@ -1,26 +1,18 @@
1
1
  import { readdirSync } from "node:fs";
2
- import { join, dirname } from "node:path";
3
- import { fileURLToPath } from "node:url";
2
+ import { join } from "node:path";
4
3
 
5
4
  let cache: { listNodePairing: Function; approveNodePairing: Function } | null = null;
6
5
 
7
6
  function resolveOpenClawDist(): string {
8
- // Walk up from the gateway-resolved SDK module to find the dist directory.
9
- // import.meta.resolve is available in Node 20.6+.
10
- try {
11
- const corePath = fileURLToPath(import.meta.resolve("openclaw/plugin-sdk/core"));
12
- return dirname(dirname(corePath)); // dist/plugin-sdk/core.js → dist/
13
- } catch {
14
- for (const root of [
15
- join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
16
- "/opt/homebrew/lib/node_modules/openclaw/dist",
17
- "/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
18
- "/usr/local/lib/node_modules/openclaw/dist",
19
- ]) {
20
- try { readdirSync(root); return root; } catch {}
21
- }
22
- throw new Error("OpenClaw dist directory not found");
7
+ for (const root of [
8
+ join(process.env.APPDATA ?? "", "npm/node_modules/openclaw/dist"),
9
+ "/opt/homebrew/lib/node_modules/openclaw/dist",
10
+ "/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw/dist",
11
+ "/usr/local/lib/node_modules/openclaw/dist",
12
+ ]) {
13
+ try { readdirSync(root); return root; } catch {}
23
14
  }
15
+ throw new Error("OpenClaw dist directory not found");
24
16
  }
25
17
 
26
18
  export async function loadNodePairingModule(): Promise<{
@@ -33,10 +25,24 @@ export async function loadNodePairingModule(): Promise<{
33
25
  (f) => f.startsWith("node-pairing-") && f.endsWith(".js") && !f.includes("authz"),
34
26
  );
35
27
  if (!file) throw new Error("node-pairing module not found in OpenClaw dist");
36
- // ESM import() correctly resolves named exports (listNodePairing, approveNodePairing)
37
- // unlike createRequire which exposes the minified export names (r, t).
38
- cache = await import(join(dist, file));
39
- return cache!;
28
+
29
+ // ESM import() returns the minified export names (r, t, …) because the
30
+ // bundled module uses `export { listNodePairing as r, … }`. Resolve the
31
+ // correct functions by Function.name, which preserves the original name.
32
+ const mod = await import(join(dist, file));
33
+ let listNodePairing: Function | undefined;
34
+ let approveNodePairing: Function | undefined;
35
+ for (const value of Object.values(mod)) {
36
+ if (typeof value === "function") {
37
+ if (value.name === "listNodePairing") listNodePairing = value;
38
+ else if (value.name === "approveNodePairing") approveNodePairing = value;
39
+ }
40
+ }
41
+ if (!listNodePairing || !approveNodePairing) {
42
+ throw new Error("node-pairing module did not export expected functions");
43
+ }
44
+ cache = { listNodePairing, approveNodePairing };
45
+ return cache;
40
46
  }
41
47
 
42
48
  /** Vitest-only: inject mock pairing functions. */