jiren 1.5.5 → 1.6.5

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.
Files changed (45) hide show
  1. package/README.md +123 -313
  2. package/components/cache.ts +1 -1
  3. package/components/client-node-native.ts +602 -159
  4. package/components/client.ts +51 -29
  5. package/components/metrics.ts +1 -4
  6. package/components/native-node.ts +48 -3
  7. package/components/native.ts +29 -0
  8. package/components/persistent-worker.ts +73 -0
  9. package/components/subprocess-worker.ts +65 -0
  10. package/components/types.ts +2 -0
  11. package/components/worker-pool.ts +169 -0
  12. package/components/worker.ts +39 -23
  13. package/dist/components/cache.d.ts +76 -0
  14. package/dist/components/cache.d.ts.map +1 -0
  15. package/dist/components/cache.js +439 -0
  16. package/dist/components/cache.js.map +1 -0
  17. package/dist/components/client-node-native.d.ts +134 -0
  18. package/dist/components/client-node-native.d.ts.map +1 -0
  19. package/dist/components/client-node-native.js +811 -0
  20. package/dist/components/client-node-native.js.map +1 -0
  21. package/dist/components/metrics.d.ts +104 -0
  22. package/dist/components/metrics.d.ts.map +1 -0
  23. package/dist/components/metrics.js +296 -0
  24. package/dist/components/metrics.js.map +1 -0
  25. package/dist/components/native-node.d.ts +67 -0
  26. package/dist/components/native-node.d.ts.map +1 -0
  27. package/dist/components/native-node.js +137 -0
  28. package/dist/components/native-node.js.map +1 -0
  29. package/dist/components/types.d.ts +252 -0
  30. package/dist/components/types.d.ts.map +1 -0
  31. package/dist/components/types.js +5 -0
  32. package/dist/components/types.js.map +1 -0
  33. package/dist/index-node.d.ts +10 -0
  34. package/dist/index-node.d.ts.map +1 -0
  35. package/dist/index-node.js +12 -0
  36. package/dist/index-node.js.map +1 -0
  37. package/dist/types/index.d.ts +63 -0
  38. package/dist/types/index.d.ts.map +1 -0
  39. package/dist/types/index.js +6 -0
  40. package/dist/types/index.js.map +1 -0
  41. package/index-node.ts +6 -6
  42. package/index.ts +4 -3
  43. package/lib/libhttpclient.dylib +0 -0
  44. package/package.json +15 -8
  45. package/types/index.ts +0 -68
@@ -0,0 +1,137 @@
1
+ import koffi from "koffi";
2
+ import path from "path";
3
+ import fs from "fs";
4
+ import { fileURLToPath } from "url";
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ // Determine library extension based on platform
8
+ const platform = process.platform;
9
+ let suffix = "so";
10
+ if (platform === "darwin") {
11
+ suffix = "dylib";
12
+ }
13
+ else if (platform === "win32") {
14
+ suffix = "dll";
15
+ }
16
+ // Resolve library path (source or dist)
17
+ let libPath = path.join(__dirname, `../lib/libhttpclient.${suffix}`);
18
+ if (!fs.existsSync(libPath)) {
19
+ // Try two levels up (for dist/components/ -> lib/)
20
+ libPath = path.join(__dirname, `../../lib/libhttpclient.${suffix}`);
21
+ }
22
+ // Load the library
23
+ // koffi.load returns an object where we can register functions
24
+ const lib = koffi.load(libPath);
25
+ // Define types if needed
26
+ // koffi handles void* as 'void*' or 'ptr'
27
+ // Struct types for pipelined batch requests
28
+ export const ZPipelineRequest = koffi.struct("ZPipelineRequest", {
29
+ method_ptr: "void *",
30
+ method_len: "uint64_t",
31
+ path_ptr: "void *",
32
+ path_len: "uint64_t",
33
+ });
34
+ export const ZPipelineResponse = koffi.struct("ZPipelineResponse", {
35
+ status: "uint16_t",
36
+ body_ptr: "void *",
37
+ body_len: "uint64_t",
38
+ headers_ptr: "void *",
39
+ headers_len: "uint64_t",
40
+ });
41
+ export const ZPipelineResult = koffi.struct("ZPipelineResult", {
42
+ responses: "void *",
43
+ count: "uint64_t",
44
+ });
45
+ export const symbols = {
46
+ zclient_new: lib.func("zclient_new", "void *", []),
47
+ zclient_free: lib.func("zclient_free", "void", ["void *"]),
48
+ zclient_get: lib.func("zclient_get", "void *", ["void *", "const char *"]),
49
+ zclient_post: lib.func("zclient_post", "void *", [
50
+ "void *",
51
+ "const char *",
52
+ "const char *",
53
+ ]),
54
+ zclient_request: lib.func("zclient_request", "void *", [
55
+ "void *", // ptr
56
+ "const char *", // method
57
+ "const char *", // url
58
+ "const char *", // headers
59
+ "const char *", // body
60
+ "uint8_t", // max_redirects
61
+ "bool", // antibot
62
+ ]),
63
+ zclient_prefetch: lib.func("zclient_prefetch", "void", [
64
+ "void *",
65
+ "const char *",
66
+ ]),
67
+ zclient_response_status: lib.func("zclient_response_status", "uint16_t", [
68
+ "void *",
69
+ ]),
70
+ zclient_response_body: lib.func("zclient_response_body", "void *", [
71
+ "void *",
72
+ ]),
73
+ zclient_response_body_len: lib.func("zclient_response_body_len", "uint64_t", [
74
+ "void *",
75
+ ]),
76
+ zclient_response_headers: lib.func("zclient_response_headers", "void *", [
77
+ "void *",
78
+ ]),
79
+ zclient_response_headers_len: lib.func("zclient_response_headers_len", "uint64_t", ["void *"]),
80
+ zclient_response_parse_header_offsets: lib.func("zclient_response_parse_header_offsets", "void *", ["void *"]),
81
+ zclient_header_offsets_free: lib.func("zclient_header_offsets_free", "void", [
82
+ "void *",
83
+ ]),
84
+ z_find_header_value: lib.func("z_find_header_value", "void *", [
85
+ "void *", // raw headers ptr
86
+ "uint64_t", // len
87
+ "const char *", // key
88
+ ]),
89
+ zclient_header_value_free: lib.func("zclient_header_value_free", "void", [
90
+ "void *",
91
+ ]),
92
+ zclient_response_free: lib.func("zclient_response_free", "void", ["void *"]),
93
+ zclient_set_benchmark_mode: lib.func("zclient_set_benchmark_mode", "void", [
94
+ "void *",
95
+ "bool",
96
+ ]),
97
+ // =========================================================================
98
+ // HTTP/1.1 PIPELINING FFI (100k RPS)
99
+ // =========================================================================
100
+ zclient_request_batch_http1: lib.func("zclient_request_batch_http1", "void *", [
101
+ "void *", // client
102
+ "const char *", // host
103
+ "uint16_t", // port
104
+ "void *", // requests array
105
+ "uint64_t", // request count
106
+ ]),
107
+ zclient_pipeline_result_free: lib.func("zclient_pipeline_result_free", "void", ["void *"]),
108
+ // =========================================================================
109
+ // CACHE FFI
110
+ // =========================================================================
111
+ zcache_new: lib.func("zcache_new", "void *", ["uint64_t"]),
112
+ zcache_free: lib.func("zcache_free", "void", ["void *"]),
113
+ zcache_get: lib.func("zcache_get", "void *", ["void *", "const char *"]),
114
+ zcache_entry_free: lib.func("zcache_entry_free", "void", ["void *"]),
115
+ zcache_set: lib.func("zcache_set", "void", [
116
+ "void *", // cache
117
+ "const char *", // key
118
+ "uint16_t", // status
119
+ "void *", // headers_ptr
120
+ "uint64_t", // headers_len
121
+ "void *", // body_ptr
122
+ "uint64_t", // body_len
123
+ "int64_t", // ttl
124
+ ]),
125
+ zcache_preload_l1: lib.func("zcache_preload_l1", "bool", [
126
+ "void *",
127
+ "const char *",
128
+ ]),
129
+ zcache_clear: lib.func("zcache_clear", "void", ["void *"]),
130
+ zcache_stats: lib.func("zcache_stats", "void *", ["void *"]),
131
+ zcache_stats_free: lib.func("zcache_stats_free", "void", ["void *"]),
132
+ };
133
+ // Export a wrapper that matches structure of bun:ffi lib
134
+ export const nativeLib = {
135
+ symbols,
136
+ };
137
+ //# sourceMappingURL=native-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-node.js","sourceRoot":"","sources":["../../components/native-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,gDAAgD;AAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;AAClC,IAAI,MAAM,GAAG,IAAI,CAAC;AAClB,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;IAC1B,MAAM,GAAG,OAAO,CAAC;AACnB,CAAC;KAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;IA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QAAQ,CAAC,CAAC;IACpE,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE;QACzC,QAAQ,EAAE,QAAQ;QAClB,cAAc,EAAE,MAAM;QACtB,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,cAAc;QACxB,UAAU,EAAE,cAAc;QAC1B,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,MAAM;KAClB,CAAC;IACF,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE;QACvD,QAAQ;QACR,cAAc;KACf,CAAC;IACF,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC1D,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC5D,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;CACrE,CAAC;AAEF,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO;CACR,CAAC"}
@@ -0,0 +1,252 @@
1
+ /**
2
+ * pow - Ultra-fast HTTP/HTTPS client powered by native Zigr than any other HTTP/HTTPS client
3
+ */
4
+ /** Options for batch HTTP requests */
5
+ export interface BatchOptions {
6
+ /** Number of requests to send (default: 1000) */
7
+ count?: number;
8
+ /** Number of concurrent threads (default: 100) */
9
+ threads?: number;
10
+ }
11
+ /** Result of a batch request operation */
12
+ export interface BatchResult {
13
+ /** Number of successful requests */
14
+ success: number;
15
+ /** Total requests attempted */
16
+ total: number;
17
+ /** Duration in seconds */
18
+ duration: number;
19
+ /** Requests per second */
20
+ requestsPerSecond: number;
21
+ }
22
+ /** Options for single HTTP requests */
23
+ export interface RequestOptions {
24
+ /** HTTP method (default: GET) */
25
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
26
+ /** Request headers */
27
+ headers?: Record<string, string>;
28
+ /** Request body (for POST, PUT, PATCH) */
29
+ body?: string | object;
30
+ /** Request timeout in milliseconds */
31
+ timeout?: number;
32
+ /** Maximum number of redirects to follow */
33
+ maxRedirects?: number;
34
+ /** Automatically parse response body */
35
+ responseType?: "json" | "text" | "arraybuffer" | "blob";
36
+ /** Enable anti-bot protection (using curl-impersonate) */
37
+ antibot?: boolean;
38
+ }
39
+ /** HTTP Response Body Wrapper */
40
+ export interface JirenResponseBody<T = any> {
41
+ /** Get response as JSON */
42
+ json: <R = T>() => Promise<R>;
43
+ /** Get response as text */
44
+ text: () => Promise<string>;
45
+ /** Get response as ArrayBuffer */
46
+ arrayBuffer: () => Promise<ArrayBuffer>;
47
+ /** Get response as Blob */
48
+ blob: () => Promise<Blob>;
49
+ /** Whether the body has been used */
50
+ bodyUsed: boolean;
51
+ }
52
+ /** HTTP Response */
53
+ export interface JirenResponse<T = any> {
54
+ /** HTTP status code */
55
+ status: number;
56
+ /** Response body object */
57
+ body: JirenResponseBody<T>;
58
+ /** Response headers */
59
+ headers: Record<string, string>;
60
+ /** Whether the request was successful (status 200-299) */
61
+ ok: boolean;
62
+ /** The URL of the response */
63
+ url: string;
64
+ /** The status message corresponding to the status code */
65
+ statusText: string;
66
+ /** Whether the response was redirected */
67
+ redirected: boolean;
68
+ /** The type of the response */
69
+ type: "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
70
+ }
71
+ /** Configuration for JirenHttpClient */
72
+ export interface JirenHttpConfig {
73
+ /** Default number of threads for batch operations */
74
+ defaultThreads?: number;
75
+ /** Base URL prefix for all requests */
76
+ baseUrl?: string;
77
+ }
78
+ /** Parsed URL components */
79
+ export interface ParsedUrl {
80
+ protocol: "http" | "https";
81
+ host: string;
82
+ port: number;
83
+ path: string;
84
+ }
85
+ /** Target URL with a key for type-safe access */
86
+ export interface TargetUrlConfig {
87
+ /** Unique key to access this URL via client.url[key] */
88
+ key: string;
89
+ /** The target URL */
90
+ url: string;
91
+ /** Enable response caching for this URL (default: false) */
92
+ cache?: boolean | CacheConfig;
93
+ /** Performance mode: disable metrics, skip cache checks for non-cached endpoints (default: true) */
94
+ performanceMode?: boolean;
95
+ /** Enable anti-bot protection for all requests to this URL (default: false) */
96
+ antibot?: boolean;
97
+ }
98
+ /** Cache configuration */
99
+ export interface CacheConfig {
100
+ /** Cache TTL in milliseconds (default: 60000 = 1 minute) */
101
+ ttl?: number;
102
+ /** Maximum cache size (default: 100 entries) */
103
+ maxSize?: number;
104
+ }
105
+ /** Configuration for automatic request retries */
106
+ export interface RetryConfig {
107
+ /** Number of retry attempts (default: 0) */
108
+ count?: number;
109
+ /** Initial delay in milliseconds before first retry (default: 100) */
110
+ delay?: number;
111
+ /** Backoff multiplier for subsequent retries (2 = double delay each time) (default: 2) */
112
+ backoff?: number;
113
+ }
114
+ /** Options for URL endpoint requests */
115
+ export interface UrlRequestOptions {
116
+ /** Request headers */
117
+ headers?: Record<string, string>;
118
+ /** Path to append to the base URL */
119
+ path?: string;
120
+ /** Request body (for POST, PUT, PATCH, DELETE) - Auto-stringifies objects */
121
+ body?: string | object | null;
122
+ /** Maximum number of redirects to follow */
123
+ maxRedirects?: number;
124
+ /** Automatically parse response body */
125
+ responseType?: "json" | "text" | "arraybuffer" | "blob";
126
+ /** Enable anti-bot protection (using curl-impersonate) */
127
+ antibot?: boolean;
128
+ /** Retry configuration for this request */
129
+ retry?: number | RetryConfig;
130
+ }
131
+ /** Interface for a URL endpoint with HTTP method helpers */
132
+ export interface UrlEndpoint {
133
+ /** GET request */
134
+ get<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
135
+ get<T = any>(options?: UrlRequestOptions & {
136
+ responseType: "json";
137
+ }): Promise<T>;
138
+ get<T = any>(options?: UrlRequestOptions & {
139
+ responseType: "text";
140
+ }): Promise<string>;
141
+ /** POST request */
142
+ post<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
143
+ post<T = any>(options?: UrlRequestOptions & {
144
+ responseType: "json";
145
+ }): Promise<T>;
146
+ /** PUT request */
147
+ put<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
148
+ put<T = any>(options?: UrlRequestOptions & {
149
+ responseType: "json";
150
+ }): Promise<T>;
151
+ /** PATCH request */
152
+ patch<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
153
+ patch<T = any>(options?: UrlRequestOptions & {
154
+ responseType: "json";
155
+ }): Promise<T>;
156
+ /** DELETE request */
157
+ delete<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
158
+ delete<T = any>(options?: UrlRequestOptions & {
159
+ responseType: "json";
160
+ }): Promise<T>;
161
+ /** HEAD request */
162
+ head(options?: UrlRequestOptions): Promise<JirenResponse<any>>;
163
+ /** OPTIONS request */
164
+ options(options?: UrlRequestOptions): Promise<JirenResponse<any>>;
165
+ /** Prefetch/refresh cache for this URL */
166
+ prefetch(options?: UrlRequestOptions): Promise<void>;
167
+ }
168
+ /** Type helper to extract keys from target config array */
169
+ export type ExtractTargetKeys<T extends readonly TargetUrlConfig[]> = T[number]["key"];
170
+ /** Context passed to request interceptors */
171
+ export interface InterceptorRequestContext {
172
+ method: string;
173
+ url: string;
174
+ headers: Record<string, string>;
175
+ body?: string | null;
176
+ path?: string;
177
+ }
178
+ /** Context passed to response interceptors */
179
+ export interface InterceptorResponseContext<T = any> {
180
+ request: InterceptorRequestContext;
181
+ response: JirenResponse<T>;
182
+ }
183
+ /** Request interceptor - can modify request before sending */
184
+ export type RequestInterceptor = (ctx: InterceptorRequestContext) => InterceptorRequestContext | Promise<InterceptorRequestContext>;
185
+ /** Response interceptor - can transform response after receiving */
186
+ export type ResponseInterceptor = <T>(ctx: InterceptorResponseContext<T>) => InterceptorResponseContext<T> | Promise<InterceptorResponseContext<T>>;
187
+ /** Error interceptor - handles errors thrown during request */
188
+ export type ErrorInterceptor = (error: Error, ctx: InterceptorRequestContext) => void | Promise<void>;
189
+ /** Interceptor configuration */
190
+ export interface Interceptors {
191
+ request?: RequestInterceptor[];
192
+ response?: ResponseInterceptor[];
193
+ error?: ErrorInterceptor[];
194
+ }
195
+ /** Metrics for a single endpoint */
196
+ export interface EndpointMetrics {
197
+ endpoint: string;
198
+ requests: {
199
+ total: number;
200
+ success: number;
201
+ failed: number;
202
+ };
203
+ statusCodes: Record<number, number>;
204
+ timing: {
205
+ avgMs: number;
206
+ minMs: number;
207
+ maxMs: number;
208
+ p50Ms: number;
209
+ p95Ms: number;
210
+ p99Ms: number;
211
+ };
212
+ cache: {
213
+ l1Hits: number;
214
+ l1Misses: number;
215
+ l2Hits: number;
216
+ l2Misses: number;
217
+ hitRate: string;
218
+ };
219
+ deduplication: {
220
+ hits: number;
221
+ misses: number;
222
+ hitRate: string;
223
+ };
224
+ bytes: {
225
+ sent: number;
226
+ received: number;
227
+ };
228
+ errors: Record<string, number>;
229
+ lastRequestAt: number | null;
230
+ }
231
+ /** Global aggregated metrics across all endpoints */
232
+ export interface GlobalMetrics {
233
+ totalRequests: number;
234
+ totalSuccess: number;
235
+ totalFailed: number;
236
+ avgResponseTimeMs: number;
237
+ totalBytesSent: number;
238
+ totalBytesReceived: number;
239
+ overallCacheHitRate: string;
240
+ overallDeduplicationRate: string;
241
+ endpoints: number;
242
+ uptime: number;
243
+ }
244
+ /** Public API for accessing metrics */
245
+ export interface MetricsAPI {
246
+ get(endpoint: string): EndpointMetrics | null;
247
+ getAll(): Record<string, EndpointMetrics>;
248
+ getGlobal(): GlobalMetrics;
249
+ reset(endpoint?: string): void;
250
+ export(): string;
251
+ }
252
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../components/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf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AM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,uCAAuC;AACvC,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;IAC9C,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1C,SAAS,IAAI,aAAa,CAAC;IAC3B,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,IAAI,MAAM,CAAC;CAClB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * pow - Ultra-fast HTTP/HTTPS client powered by native Zigr than any other HTTP/HTTPS client
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../components/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * jiren - Ultra-fast HTTP/HTTPS client (Node.js Native)
3
+ *
4
+ * Use the same high-performance Zig backend as Bun.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export { JirenClient, type JirenClientOptions, type UrlAccessor, } from "./components/client-node-native.js";
9
+ export * from "./components/types.js";
10
+ //# sourceMappingURL=index-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../index-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,WAAW,GACjB,MAAM,oCAAoC,CAAC;AAI5C,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * jiren - Ultra-fast HTTP/HTTPS client (Node.js Native)
3
+ *
4
+ * Use the same high-performance Zig backend as Bun.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ // Main client (Node.js Native)
9
+ export { JirenClient, } from "./components/client-node-native.js";
10
+ // Types
11
+ export * from "./components/types.js";
12
+ //# sourceMappingURL=index-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node.js","sourceRoot":"","sources":["../index-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,+BAA+B;AAC/B,OAAO,EACL,WAAW,GAGZ,MAAM,oCAAoC,CAAC;AAE5C,QAAQ;AAER,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * jiren - Ultra-fast HTTP/HTTPS Client Types
3
+ * 56% faster than llhttp
4
+ */
5
+ /** Options for batch HTTP requests */
6
+ export interface BatchOptions {
7
+ /** Number of requests to send (default: 1000) */
8
+ count?: number;
9
+ /** Number of concurrent threads (default: 100) */
10
+ threads?: number;
11
+ }
12
+ /** Result of a batch request operation */
13
+ export interface BatchResult {
14
+ /** Number of successful requests */
15
+ success: number;
16
+ /** Total requests attempted */
17
+ total: number;
18
+ /** Duration in seconds */
19
+ duration: number;
20
+ /** Requests per second */
21
+ requestsPerSecond: number;
22
+ }
23
+ /** Options for single HTTP requests */
24
+ export interface RequestOptions {
25
+ /** HTTP method (default: GET) */
26
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
27
+ /** Request headers */
28
+ headers?: Record<string, string>;
29
+ /** Request body (for POST, PUT, PATCH) */
30
+ body?: string | object;
31
+ /** Request timeout in milliseconds */
32
+ timeout?: number;
33
+ /** Maximum number of redirects to follow */
34
+ maxRedirects?: number;
35
+ /** Automatically parse response body */
36
+ responseType?: "json" | "text" | "arraybuffer" | "blob";
37
+ /** Enable anti-bot protection (using curl-impersonate) */
38
+ antibot?: boolean;
39
+ }
40
+ /** HTTP Response */
41
+ export interface HttpResponse {
42
+ /** HTTP status code */
43
+ status: number;
44
+ /** Response body as string */
45
+ body: string;
46
+ /** Response headers */
47
+ headers?: Record<string, string>;
48
+ }
49
+ /** Configuration for JirenHttpClient */
50
+ export interface JirenHttpConfig {
51
+ /** Default number of threads for batch operations */
52
+ defaultThreads?: number;
53
+ /** Base URL prefix for all requests */
54
+ baseUrl?: string;
55
+ }
56
+ /** Parsed URL components */
57
+ export interface ParsedUrl {
58
+ protocol: "http" | "https";
59
+ host: string;
60
+ port: number;
61
+ path: string;
62
+ }
63
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAC9D,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;IACxD,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,oBAAoB;AACpB,MAAM,WAAW,YAAY;IAC3B,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,4BAA4B;AAC5B,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * jiren - Ultra-fast HTTP/HTTPS Client Types
3
+ * 56% faster than llhttp
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
package/index-node.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
- * jiren - Ultra-fast HTTP/HTTPS client (Node.js/Next.js Fallback)
2
+ * jiren - Ultra-fast HTTP/HTTPS client (Node.js Native)
3
3
  *
4
- * NOTE: This is the Node.js compatible version using standard fetch.
5
- * For maximum performance with native Zig bindings, use Bun.
4
+ * Use the same high-performance Zig backend as Bun.
6
5
  *
7
6
  * @packageDocumentation
8
7
  */
9
8
 
10
- // Main client (Node.js fallback)
9
+ // Main client (Node.js Native)
11
10
  export {
12
11
  JirenClient,
13
12
  type JirenClientOptions,
14
13
  type UrlAccessor,
15
- } from "./components/client-node-native";
14
+ } from "./components/client-node-native.js";
16
15
 
17
16
  // Types
18
- export * from "./types";
17
+
18
+ export * from "./components/types.js";
package/index.ts CHANGED
@@ -22,12 +22,13 @@
22
22
  * @packageDocumentation
23
23
  */
24
24
 
25
+ // Main client
25
26
  // Main client
26
27
  export {
27
28
  JirenClient,
28
- type JirenResponse,
29
- type JirenResponseBody,
29
+ type JirenClientOptions,
30
+ type UrlAccessor,
30
31
  } from "./components";
31
32
 
32
33
  // Types
33
- export * from "./types";
34
+ export * from "./components/types";
Binary file
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "jiren",
3
- "version": "1.5.5",
3
+ "version": "1.6.5",
4
4
  "author": "",
5
5
  "main": "index.ts",
6
6
  "module": "index.ts",
7
7
  "types": "index.ts",
8
8
  "devDependencies": {
9
- "@types/bun": "^1.3.4"
9
+ "@types/bun": "^1.3.4",
10
+ "@types/node": "^22.0.0"
10
11
  },
11
12
  "peerDependencies": {
12
13
  "typescript": "^5"
@@ -17,7 +18,8 @@
17
18
  "index-node.ts",
18
19
  "types",
19
20
  "lib",
20
- "components"
21
+ "components",
22
+ "dist"
21
23
  ],
22
24
  "keywords": [
23
25
  "http",
@@ -29,12 +31,17 @@
29
31
  "benchmark",
30
32
  "performance",
31
33
  "bun",
34
+ "node",
32
35
  "parser"
33
36
  ],
34
37
  "license": "MIT",
35
38
  "scripts": {
36
- "build:zig": "cd .. && zig build --release=fast",
37
- "test": "bun run examples/basic.ts"
39
+ "build:zig": "cd .. && zig build --release=fast && cp zig-out/lib/libhttpclient.dylib jiren/lib/",
40
+ "build:node": "tsc -p tsconfig.node.json",
41
+ "build": "npm run build:node",
42
+ "prepublishOnly": "npm run build",
43
+ "test": "bun run examples/basic.ts",
44
+ "test:node": "node --experimental-strip-types test-node.mjs"
38
45
  },
39
46
  "engines": {
40
47
  "node": ">=18.0.0",
@@ -44,9 +51,9 @@
44
51
  "exports": {
45
52
  ".": {
46
53
  "bun": "./index.ts",
47
- "default": "./index-node.ts"
48
- },
49
- "./package.json": "./package.json"
54
+ "import": "./dist/index-node.js",
55
+ "types": "./dist/index-node.d.ts"
56
+ }
50
57
  },
51
58
  "dependencies": {
52
59
  "koffi": "^2.14.1"