jiren 1.0.5 → 1.0.6

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.
@@ -0,0 +1,29 @@
1
+ import type { RequestOptions, GetRequestOptions, PostRequestOptions, HttpResponse } from "../types";
2
+ export declare class JirenClient {
3
+ private ptr;
4
+ constructor();
5
+ /**
6
+ * Free the native client resources.
7
+ * Must be called when the client is no longer needed.
8
+ */
9
+ close(): void;
10
+ /**
11
+ * Perform a HTTP request.
12
+ * @param url - The URL to request
13
+ * @param options - Request options (method, headers, body)
14
+ * @returns Response object
15
+ */
16
+ request(url: string, options?: RequestOptions): HttpResponse;
17
+ get(url: string, options?: GetRequestOptions): HttpResponse;
18
+ post(url: string, body: string | object, options?: PostRequestOptions): HttpResponse;
19
+ put(url: string, body: string | object, options?: PostRequestOptions): HttpResponse;
20
+ delete(url: string, options?: GetRequestOptions): HttpResponse;
21
+ patch(url: string, body: string | object, options?: PostRequestOptions): HttpResponse;
22
+ head(url: string, options?: GetRequestOptions): HttpResponse;
23
+ /**
24
+ * Prefetch URLs to warm up connections (resolve DNS & Handshake).
25
+ * @param urls - List of URLs to prefetch
26
+ */
27
+ prefetch(urls: string[]): void;
28
+ private parseResponse;
29
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * flous - Ultra-fast HTTP/HTTPS client powered by native Zig
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { JirenClient } from "./client";
7
+ export type { JirenHttpConfig, ParsedUrl } from "../types/index";
@@ -0,0 +1,101 @@
1
+ import { FFIType } from "bun:ffi";
2
+ export declare const ffiDef: {
3
+ readonly zclient_new: {
4
+ readonly args: readonly [];
5
+ readonly returns: FFIType.ptr;
6
+ };
7
+ readonly zclient_free: {
8
+ readonly args: readonly [FFIType.ptr];
9
+ readonly returns: FFIType.void;
10
+ };
11
+ readonly zclient_get: {
12
+ readonly args: readonly [FFIType.ptr, FFIType.cstring];
13
+ readonly returns: FFIType.ptr;
14
+ };
15
+ readonly zclient_post: {
16
+ readonly args: readonly [FFIType.ptr, FFIType.cstring, FFIType.cstring];
17
+ readonly returns: FFIType.ptr;
18
+ };
19
+ readonly zclient_prefetch: {
20
+ readonly args: readonly [FFIType.ptr, FFIType.cstring];
21
+ readonly returns: FFIType.void;
22
+ };
23
+ readonly zclient_response_status: {
24
+ readonly args: readonly [FFIType.ptr];
25
+ readonly returns: FFIType.uint16_t;
26
+ };
27
+ readonly zclient_response_body: {
28
+ readonly args: readonly [FFIType.ptr];
29
+ readonly returns: FFIType.ptr;
30
+ };
31
+ readonly zclient_response_body_len: {
32
+ readonly args: readonly [FFIType.ptr];
33
+ readonly returns: FFIType.uint64_t;
34
+ };
35
+ readonly zclient_response_headers: {
36
+ readonly args: readonly [FFIType.ptr];
37
+ readonly returns: FFIType.ptr;
38
+ };
39
+ readonly zclient_response_headers_len: {
40
+ readonly args: readonly [FFIType.ptr];
41
+ readonly returns: FFIType.uint64_t;
42
+ };
43
+ readonly zclient_response_free: {
44
+ readonly args: readonly [FFIType.ptr];
45
+ readonly returns: FFIType.void;
46
+ };
47
+ readonly zclient_request: {
48
+ readonly args: readonly [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring];
49
+ readonly returns: FFIType.ptr;
50
+ };
51
+ };
52
+ export declare const lib: import("bun:ffi").Library<{
53
+ readonly zclient_new: {
54
+ readonly args: readonly [];
55
+ readonly returns: FFIType.ptr;
56
+ };
57
+ readonly zclient_free: {
58
+ readonly args: readonly [FFIType.ptr];
59
+ readonly returns: FFIType.void;
60
+ };
61
+ readonly zclient_get: {
62
+ readonly args: readonly [FFIType.ptr, FFIType.cstring];
63
+ readonly returns: FFIType.ptr;
64
+ };
65
+ readonly zclient_post: {
66
+ readonly args: readonly [FFIType.ptr, FFIType.cstring, FFIType.cstring];
67
+ readonly returns: FFIType.ptr;
68
+ };
69
+ readonly zclient_prefetch: {
70
+ readonly args: readonly [FFIType.ptr, FFIType.cstring];
71
+ readonly returns: FFIType.void;
72
+ };
73
+ readonly zclient_response_status: {
74
+ readonly args: readonly [FFIType.ptr];
75
+ readonly returns: FFIType.uint16_t;
76
+ };
77
+ readonly zclient_response_body: {
78
+ readonly args: readonly [FFIType.ptr];
79
+ readonly returns: FFIType.ptr;
80
+ };
81
+ readonly zclient_response_body_len: {
82
+ readonly args: readonly [FFIType.ptr];
83
+ readonly returns: FFIType.uint64_t;
84
+ };
85
+ readonly zclient_response_headers: {
86
+ readonly args: readonly [FFIType.ptr];
87
+ readonly returns: FFIType.ptr;
88
+ };
89
+ readonly zclient_response_headers_len: {
90
+ readonly args: readonly [FFIType.ptr];
91
+ readonly returns: FFIType.uint64_t;
92
+ };
93
+ readonly zclient_response_free: {
94
+ readonly args: readonly [FFIType.ptr];
95
+ readonly returns: FFIType.void;
96
+ };
97
+ readonly zclient_request: {
98
+ readonly args: readonly [FFIType.ptr, FFIType.cstring, FFIType.cstring, FFIType.cstring, FFIType.cstring];
99
+ readonly returns: FFIType.ptr;
100
+ };
101
+ }>;
@@ -0,0 +1,55 @@
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
+ }
33
+ /** HTTP Response */
34
+ export interface HttpResponse {
35
+ /** HTTP status code */
36
+ status: number;
37
+ /** Response body as string */
38
+ body: string;
39
+ /** Response headers */
40
+ headers?: Record<string, string>;
41
+ }
42
+ /** Configuration for JirenHttpClient */
43
+ export interface JirenHttpConfig {
44
+ /** Default number of threads for batch operations */
45
+ defaultThreads?: number;
46
+ /** Base URL prefix for all requests */
47
+ baseUrl?: string;
48
+ }
49
+ /** Parsed URL components */
50
+ export interface ParsedUrl {
51
+ protocol: "http" | "https";
52
+ host: string;
53
+ port: number;
54
+ path: string;
55
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * jiren - Ultra-fast HTTP/HTTPS client powered by native Zig
3
+ *
4
+ * Faster than any other HTTP/HTTPS client | 1.5M+ requests/sec
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { JirenClient } from 'jiren';
9
+ *
10
+ * const client = new JirenClient();
11
+ *
12
+ * // High-performance batch requests
13
+ * const result = client.batch('http://localhost:3000/', {
14
+ * count: 10000,
15
+ * threads: 100
16
+ * });
17
+ *
18
+ * console.log(`Success: ${result.success}/${result.total}`);
19
+ * console.log(`Speed: ${result.requestsPerSecond.toFixed(0)} req/sec`);
20
+ * ```
21
+ *
22
+ * @packageDocumentation
23
+ */
24
+ export { JirenClient } from "./components";
25
+ export * from "./types";
package/dist/test.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
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
+ /** Options for single HTTP requests */
25
+ export interface RequestOptions {
26
+ /** HTTP method (default: GET) */
27
+ method?: string;
28
+ /** Request headers */
29
+ headers?: Record<string, string>;
30
+ /** Request body (for POST, PUT, PATCH) */
31
+ body?: string | object;
32
+ /** Request timeout in milliseconds */
33
+ timeout?: number;
34
+ /** Maximum number of redirects to follow (default: 0) */
35
+ maxRedirects?: number;
36
+ }
37
+ /** Options for requests without a body (GET, DELETE, HEAD) */
38
+ export type GetRequestOptions = Omit<RequestOptions, "method" | "body">;
39
+ /** Options for requests with a body (POST, PUT, PATCH) where body is a separate argument */
40
+ export type PostRequestOptions = Omit<RequestOptions, "method" | "body">;
41
+ /** HTTP Response */
42
+ export interface HttpResponse {
43
+ /** HTTP status code */
44
+ status: number;
45
+ /** Response body as string */
46
+ body: string;
47
+ /** Response headers */
48
+ headers?: Record<string, string>;
49
+ /** True if status is 2xx */
50
+ ok: boolean;
51
+ /** Helper to get body as string (Promise for Fetch compatibility) */
52
+ text: () => Promise<string>;
53
+ /** Helper to parse JSON body */
54
+ json: <T = any>() => T;
55
+ }
56
+ /** Configuration for JirenHttpClient */
57
+ export interface JirenHttpConfig {
58
+ /** Default number of threads for batch operations */
59
+ defaultThreads?: number;
60
+ /** Base URL prefix for all requests */
61
+ baseUrl?: string;
62
+ }
63
+ /** Parsed URL components */
64
+ export interface ParsedUrl {
65
+ protocol: "http" | "https";
66
+ host: string;
67
+ port: number;
68
+ path: string;
69
+ }
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "jiren",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "author": "",
5
5
  "main": "index.ts",
6
6
  "module": "index.ts",
7
- "types": "index.ts",
7
+ "types": "dist/index.d.ts",
8
8
  "dependencies": {
9
9
  "@types/bun": "^1.3.4"
10
10
  },
11
- "devDependencies": {},
11
+ "devDependencies": {
12
+ "typescript": "^5"
13
+ },
12
14
  "peerDependencies": {
13
15
  "typescript": "^5"
14
16
  },
@@ -16,6 +18,7 @@
16
18
  "files": [
17
19
  "index.ts",
18
20
  "types",
21
+ "dist",
19
22
  "lib",
20
23
  "components"
21
24
  ],
@@ -33,6 +36,7 @@
33
36
  ],
34
37
  "license": "MIT",
35
38
  "scripts": {
39
+ "build": "tsc",
36
40
  "build:zig": "cd .. && zig build --release=fast",
37
41
  "test": "bun run examples/basic.ts"
38
42
  },