{"name":"@cspell/rpc","version":"10.3.5","keywords":["cspell","RPC","TypeScript"],"author":{"name":"Jason Dent","email":"jason@streetsidesoftware.nl"},"license":"MIT","_id":"@cspell/rpc@10.3.5","maintainers":[{"name":"jason-dent","email":"jason@streetsidesoftware.nl"}],"homepage":"https://github.com/streetsidesoftware/cspell/tree/main/packages/rpc#readme","bugs":{"url":"https://github.com/streetsidesoftware/cspell"},"dist":{"shasum":"eb00152b516c63d6f8e9e2e530c82c1da40e26fe","tarball":"http://registry-npm.ywwl.com/@cspell/rpc/download/@cspell/rpc-10.3.5.tgz","fileCount":5,"integrity":"sha512-+Yei/jfo8anBaRM6eAaV6+W3FvpQX+Ethe+llZRVM4BnSVc8FLoNkTQiZUTrFq85KPDnmAfyI1Q77Fea3rKekA==","signatures":[{"sig":"MEUCIQDhpsOxf+YUpdFbuYQbkJSygn2elrYMg0k16goAx69sOAIgbNrZWa88DdcXteMyeRZ/sG9wi6DXFdt56uEyUGjtC5g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIEGtmypVdZuJnKLVRMv9bo8Thy+QwSWqvqumzROYuxW5AiEAsOOKgdi3aKNwR8/WMmN7TIMo/MKrUOW49b3//F6OOKc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@cspell%2frpc@10.3.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":49214,"size":11674,"noattachment":false,"key":"/@cspell/rpc/-/@cspell/rpc-10.3.5.tgz"},"type":"module","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js"},"gitHead":"f37a244a54b686fc1ac11272d6019b9a059b062a","scripts":{"test":"vitest run --pool=forks","build":"tsdown && tsc -p .","clean":"shx rm -rf dist temp coverage \"*.tsbuildInfo\"","watch":"tsdown --watch","coverage":"vitest run --coverage --pool=forks","clean-build":"pnpm run clean && pnpm run build"},"typings":"dist/index.d.ts","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:5f4c29b9-9b7f-4dd1-90a2-fe595b9d7850"}},"repository":{"url":"git+https://github.com/streetsidesoftware/cspell.git","type":"git","directory":"packages/rpc"},"_npmVersion":"lerna/5.6.1/node@v24.21.0+x64 (linux)","description":"Type Safe RPC library.","directories":{"dist":"dist"},"sideEffects":false,"_nodeVersion":"24.21.0","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/rpc_10.3.5_1790540414862_0.5808257305862461","host":"s3://npm-registry-packages-npm-production"},"readme":"# Simple RPC\n\nA basic client / server RPC for sending the requests over a MessagePort.\n\nThis supports Node Worker Threads, Web Workers, or anything that can provide a MessagePortLike interface.\n\n## Communication Details\n\nThe client and server communicate by sending messages over the MessagePort.\n\n```ts\nexport interface RPCMessage {\n  sig: 'RPC0';\n  /**\n   * A Unique identifier for the request/response.\n   * Ideally this is a randomUUID.\n   */\n  id: RequestID;\n  /**\n   * The type of message being sent.\n   */\n  type: 'request' | 'response' | 'cancel' | 'canceled' | 'ok' | 'ready';\n}\n\nexport type RPCRequestType = 'request' | 'cancel' | 'ok' | 'ready';\n\nexport type RPCResponseType = 'response' | 'canceled' | 'ok' | 'ready';\n```\n\nThere are two types of messages: Request and Response. The client sends requests and the server sends responses.\n\n### RPC Request\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    participant W as Worker\n    C->>+S: Request <id>\n    S->>+W: Method\n    W->>-S: Result\n    S->>-C: Response <id>, Result\n```\n\n### RPC Request with ACK\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    participant W as Worker\n    C->>+S: Request <id>, ACK\n    S->>C: ACK <id>\n    S->>+W: Method\n    W->>-S: Result\n    S->>-C: Response <id>, Result\n```\n\n### RPC Request with Error\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    participant W as Worker\n    C->>+S: Request <id>, ACK\n    S->>C: ACK <id>\n    S->>+W: Method\n    W->>-S: Error\n    S->>-C: Response <id>, Error\n```\n\n### OK Request\n\nThis request is used to check if the server is ok.\n\n```mermaid\nsequenceDiagram\n    Client->>Server: OK <id>?\n    Server->>Client: OK <id>, Code 200\n```\n\n### Cancel Request\n\nA cancellation request is used to cancel or abort a request. The server accepts the request and acknowledges that it was received. Depending on the mode, the server either responds immediately without waiting for the worker to confirm the cancellation, or waits for that confirmation before responding:\n\n#### Cancel Request: no wait\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    participant W as Worker\n    C->>+S: Request <id>\n    S->>+W: Method\n    C->>S: Cancel <id>\n    S->>-C: Canceled <id>\n    S--xW: Cancel\n    W--x-S: Canceled\n```\n\n#### Cancel Request: wait\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    participant W as Worker\n    C->>+S: Request <id>\n    S->>+W: Method\n    C->>S: Cancel <id>, Wait\n    S--xW: Cancel\n    W-->>-S: Canceled\n    S->>-C: Canceled <id>\n```\n\n### RPC Request, Canceled by Server\n\nIt can happen that the server needs to cancel requests. This can happen if the server is getting disposed and still has pending requests. It has a couple of ways to do this:\n\n1. Send an Error Response\n2. Send a Canceled Response\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    participant W as Worker\n    C->>+S: Request <id>\n    S->>+W: Method\n    W--x-S: Canceled\n    S->>-C: Canceled <id>\n```\n\n### Abort\n\nAn abort request is the same as a Cancel request, only the client will not wait on a response and the response will be ignored.\n\n```mermaid\nsequenceDiagram\n    participant C as Client\n    participant S as Server\n    C->>S: Request <id>\n    C-->>S: Cancel <id>\n    S--xC: Canceled <id>\n```\n","publish_time":1790540414950,"_cnpm_publish_time":1790540414950,"dist-tags":{"latest":"10.4.1","next":"10.4.0-alpha.1"}}