@pyrpc/client 0.3.1 → 0.3.3

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/index.d.mts CHANGED
@@ -25,7 +25,7 @@ interface ClientOptions {
25
25
  }
26
26
 
27
27
  declare class PyRPCClient {
28
- private baseUrl;
28
+ private url;
29
29
  private options;
30
30
  constructor(options?: ClientOptions);
31
31
  /**
@@ -40,7 +40,7 @@ declare class PyRPCClient {
40
40
  /**
41
41
  * Modern factory API for pyRPC.
42
42
  */
43
- declare function createClient<TTypes = any>(options?: ClientOptions): PyRPCClient & TTypes;
43
+ declare function createClient<TTypes = any>(options?: ClientOptions): TTypes;
44
44
 
45
45
  declare class PyRPCError extends Error {
46
46
  readonly code: number;
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ interface ClientOptions {
25
25
  }
26
26
 
27
27
  declare class PyRPCClient {
28
- private baseUrl;
28
+ private url;
29
29
  private options;
30
30
  constructor(options?: ClientOptions);
31
31
  /**
@@ -40,7 +40,7 @@ declare class PyRPCClient {
40
40
  /**
41
41
  * Modern factory API for pyRPC.
42
42
  */
43
- declare function createClient<TTypes = any>(options?: ClientOptions): PyRPCClient & TTypes;
43
+ declare function createClient<TTypes = any>(options?: ClientOptions): TTypes;
44
44
 
45
45
  declare class PyRPCError extends Error {
46
46
  readonly code: number;
package/dist/index.js CHANGED
@@ -52,7 +52,7 @@ createClient({
52
52
  })
53
53
  `;
54
54
  var PyRPCClient = class {
55
- baseUrl;
55
+ url;
56
56
  options;
57
57
  constructor(options = {}) {
58
58
  let baseUrl = options.baseUrl;
@@ -63,7 +63,8 @@ var PyRPCClient = class {
63
63
  throw new Error(NO_BASE_URL_ERROR);
64
64
  }
65
65
  }
66
- this.baseUrl = baseUrl.replace(/\/$/, "");
66
+ const clean = baseUrl.replace(/\/+$/, "");
67
+ this.url = clean.replace(/\/rpc$/i, "") + "/rpc";
67
68
  this.options = options;
68
69
  }
69
70
  /**
@@ -80,7 +81,7 @@ var PyRPCClient = class {
80
81
  userHeaders = typeof this.options.headers === "function" ? await this.options.headers() : this.options.headers;
81
82
  }
82
83
  const headers = { ...baseHeaders, ...Object.fromEntries(new Headers(userHeaders).entries()) };
83
- const response = await fetch(`${this.baseUrl}/rpc`, {
84
+ const response = await fetch(this.url, {
84
85
  method: "POST",
85
86
  headers,
86
87
  body: JSON.stringify(body)
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ createClient({
24
24
  })
25
25
  `;
26
26
  var PyRPCClient = class {
27
- baseUrl;
27
+ url;
28
28
  options;
29
29
  constructor(options = {}) {
30
30
  let baseUrl = options.baseUrl;
@@ -35,7 +35,8 @@ var PyRPCClient = class {
35
35
  throw new Error(NO_BASE_URL_ERROR);
36
36
  }
37
37
  }
38
- this.baseUrl = baseUrl.replace(/\/$/, "");
38
+ const clean = baseUrl.replace(/\/+$/, "");
39
+ this.url = clean.replace(/\/rpc$/i, "") + "/rpc";
39
40
  this.options = options;
40
41
  }
41
42
  /**
@@ -52,7 +53,7 @@ var PyRPCClient = class {
52
53
  userHeaders = typeof this.options.headers === "function" ? await this.options.headers() : this.options.headers;
53
54
  }
54
55
  const headers = { ...baseHeaders, ...Object.fromEntries(new Headers(userHeaders).entries()) };
55
- const response = await fetch(`${this.baseUrl}/rpc`, {
56
+ const response = await fetch(this.url, {
56
57
  method: "POST",
57
58
  headers,
58
59
  body: JSON.stringify(body)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyrpc/client",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Universal TypeScript client for pyRPC",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -24,7 +24,7 @@
24
24
  "author": "",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@pyrpc/types": "^0.1.0-alpha.1"
27
+ "@pyrpc/types": "^0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^20.19.39",