jiren 3.8.0 → 3.9.0

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.
@@ -3,10 +3,7 @@ import { JirenClient as FetchJirenClient } from "./client-node-fetch";
3
3
  import { isNativeAvailable } from "./native";
4
4
 
5
5
  const forceFallback = process.env.JIREN_FORCE_FETCH_FALLBACK === "1";
6
- const isWindows = process.platform === "win32";
7
6
 
8
7
  export const JirenClient = (
9
- !forceFallback && !isWindows && isNativeAvailable
10
- ? NativeJirenClient
11
- : FetchJirenClient
8
+ !forceFallback && isNativeAvailable ? NativeJirenClient : FetchJirenClient
12
9
  ) as unknown as typeof NativeJirenClient;
@@ -1,9 +1,38 @@
1
1
  import { dlopen, FFIType, suffix } from "bun:ffi";
2
2
  import fs from "fs";
3
- import { join } from "path";
3
+ import { delimiter, dirname, join } from "path";
4
4
 
5
5
  // Reverted to flat structure
6
6
  const libPath = join(import.meta.dir, `../lib/libhttpclient.${suffix}`);
7
+ const libDir = dirname(libPath);
8
+
9
+ if (process.platform === "win32") {
10
+ // Ensure dependent DLLs (e.g. libcurl.dll, zlib1.dll) in jiren/lib are discoverable.
11
+ const currentPath = process.env.PATH ?? process.env.Path ?? "";
12
+ const hasLibDir = currentPath
13
+ .split(delimiter)
14
+ .some((entry) => entry.toLowerCase() === libDir.toLowerCase());
15
+ if (!hasLibDir) {
16
+ const nextPath = `${libDir}${delimiter}${currentPath}`;
17
+ process.env.PATH = nextPath;
18
+ process.env.Path = nextPath;
19
+ }
20
+ }
21
+
22
+ const preloadedWindowsDeps: Array<ReturnType<typeof dlopen>> = [];
23
+
24
+ if (process.platform === "win32") {
25
+ const dependencies = ["zlib1.dll", "libcurl.dll"];
26
+ for (const dependency of dependencies) {
27
+ const dependencyPath = join(libDir, dependency);
28
+ if (!fs.existsSync(dependencyPath)) continue;
29
+ try {
30
+ preloadedWindowsDeps.push(dlopen(dependencyPath, {} as any));
31
+ } catch {
32
+ // Best-effort: dlopen of libhttpclient.dll may still succeed via PATH/system lookup.
33
+ }
34
+ }
35
+ }
7
36
 
8
37
  export const ffiDef = {
9
38
  zclient_new: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jiren",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "author": "",
5
5
  "main": "index.ts",
6
6
  "module": "index.ts",