@irpclib/irpc 0.0.1 → 0.0.2

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.js CHANGED
@@ -2,7 +2,7 @@ import { batch } from "./batch.js";
2
2
  import { shortId } from "./utils.js";
3
3
  import { IRPCCall } from "./call.js";
4
4
  import { createContext, getContext, setContext, setContextProvider, withContext } from "./context.js";
5
- import { IRPCTransport } from "./types.js";
6
5
  import { createModule } from "./module.js";
6
+ import { IRPCTransport } from "./types.js";
7
7
 
8
8
  export { IRPCCall, IRPCTransport, batch, createContext, createModule, getContext, setContext, setContextProvider, shortId, withContext };
package/dist/module.js CHANGED
@@ -17,7 +17,7 @@ function createModule(config) {
17
17
  const store = /* @__PURE__ */ new Map();
18
18
  const registry = /* @__PURE__ */ new WeakMap();
19
19
  const module = {
20
- name: "irpc",
20
+ name: "global",
21
21
  version: "1.0.0",
22
22
  timeout: DEFAULT_TIMEOUT,
23
23
  ...config
@@ -44,6 +44,18 @@ function createModule(config) {
44
44
  version: module.version
45
45
  }) });
46
46
  /**
47
+ * Returns the endpoint URL for the module.
48
+ * @type {(prefix?: string) => string}
49
+ */
50
+ factory.endpoint = ((prefix = "irpc") => {
51
+ return [
52
+ "/",
53
+ prefix,
54
+ module.name,
55
+ module.version
56
+ ].join("/").replace(/\/+/g, "/");
57
+ });
58
+ /**
47
59
  * Associates a handler function with an IRPC specification.
48
60
  * @param irpc - The IRPC function to construct
49
61
  * @param handler - The actual implementation of the IRPC function
package/dist/types.d.ts CHANGED
@@ -137,6 +137,11 @@ interface IRPCFactory {
137
137
  <F, I extends IRPCInputs = IRPCInputs, O extends IRPCOutput = IRPCOutput>(spec: IRPCSpec<I, O>): F;
138
138
  /** The namespace associated with this factory */
139
139
  get namespace(): IRPCNamespace;
140
+ /**
141
+ * Gets the endpoint URL for this factory.
142
+ * @param prefix Optional prefix to prepend to the endpoint, default to '/irpc'
143
+ */
144
+ endpoint(prefix?: string): string;
140
145
  /**
141
146
  * Sets the transport mechanism for this factory.
142
147
  * @param transport The transport to use
package/dist/utils.js CHANGED
@@ -3,15 +3,15 @@ let lastTimestamp = 0;
3
3
  let sequence = 0;
4
4
  /**
5
5
  * Generates a short unique identifier string.
6
- *
6
+ *
7
7
  * This function creates a unique ID by combining:
8
8
  * - A timestamp in base-36 format
9
9
  * - A sequence number in base-36 format (padded to 3 characters)
10
10
  * - A random string in base-36 format (4 characters)
11
- *
11
+ *
12
12
  * The sequence number ensures uniqueness when multiple IDs are generated within the same millisecond.
13
13
  * The random part adds additional entropy to reduce predictability.
14
- *
14
+ *
15
15
  * @returns A unique string identifier
16
16
  */
17
17
  function shortId() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@irpclib/irpc",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "types": "./dist/index.d.ts",
6
6
  "module": "./dist/index.js",
7
7
  "exports": {
@@ -28,7 +28,7 @@
28
28
  "publint": "^0.3.15",
29
29
  "rimraf": "^6.0.1",
30
30
  "tsdown": "^0.15.9",
31
- "vite": "^7.1.12",
31
+ "vite": "^7.1.10",
32
32
  "vitest": "^3.2.4",
33
33
  "zod": "^4.1.5",
34
34
  "@types/bun": "1.3.1"
@@ -43,7 +43,7 @@
43
43
  "dev": "tsdown --watch",
44
44
  "clean": "rimraf dist",
45
45
  "build": "tsdown && publint",
46
- "format": "prettier --write .",
46
+ "format": "biome format --write",
47
47
  "test": "rimraf coverage && vitest --run",
48
48
  "test:preview": "rimraf coverage && vitest --run && vite preview --outDir coverage",
49
49
  "prepublish": "bun run format && bun run clean && tsdown && publint"