{"_id":"@atlaschain/rpc-subscriptions-channel-websocket","name":"@atlaschain/rpc-subscriptions-channel-websocket","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@atlaschain/rpc-subscriptions-channel-websocket","version":"3.0.0","description":"An RPC Subscriptions transport that uses WebSockets","exports":{"edge-light":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"workerd":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"browser":{"import":"./dist/index.browser.mjs","require":"./dist/index.browser.cjs"},"node":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"react-native":"./dist/index.native.mjs","types":"./dist/types/index.d.ts"},"browser":{"./dist/index.node.cjs":"./dist/index.browser.cjs","./dist/index.node.mjs":"./dist/index.browser.mjs"},"main":"./dist/index.node.cjs","module":"./dist/index.node.mjs","react-native":"./dist/index.native.mjs","types":"./dist/types/index.d.ts","type":"commonjs","sideEffects":false,"keywords":["blockchain","atlas","web3"],"author":{"name":"Atlas Chain Foundation"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/anza-xyz/kit.git"},"bugs":{"url":"https://github.com/anza-xyz/kit/issues"},"browserslist":["supports bigint and not dead","maintained node versions"],"dependencies":{"@atlaschain/rpc-subscriptions-spec":"3.0.0","@atlaschain/subscribable":"3.0.0","@atlaschain/errors":"3.0.0","@atlaschain/functional":"3.0.0"},"peerDependencies":{"typescript":">=5.3.3","ws":"^8.18.0"},"engines":{"node":">=20.18.0"},"scripts":{"compile:docs":"typedoc","compile:js":"tsup --config build-scripts/tsup.config.package.ts","compile:typedefs":"tsc -p ./tsconfig.declarations.json","dev":"jest -c ../../node_modules/@atlaschain/test-config/jest-dev.config.ts --rootDir . --watch","publish-impl":"npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || (pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks && (([ -n \"${GITHUB_OUTPUT:-}\" ] && echo 'published=true' >> \"$GITHUB_OUTPUT\") || true) && (([ \"$PUBLISH_TAG\" != \"canary\" ] && ../build-scripts/maybe-tag-latest.ts $npm_package_name@$npm_package_version) || true))","publish-packages":"pnpm prepublishOnly && pnpm publish-impl","style:fix":"pnpm eslint --fix src && pnpm prettier --log-level warn --ignore-unknown --write ./*","test:lint":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-lint.config.ts --rootDir . --silent","test:prettier":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-prettier.config.ts --rootDir . --silent","test:treeshakability:browser":"agadoo dist/index.browser.mjs","test:treeshakability:native":"agadoo dist/index.native.mjs","test:treeshakability:node":"agadoo dist/index.node.mjs","test:typecheck":"tsc --noEmit","test:unit:browser":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-unit.config.browser.ts --rootDir . --silent","test:unit:node":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-unit.config.node.ts --rootDir . --silent"},"_id":"@atlaschain/rpc-subscriptions-channel-websocket@3.0.0","homepage":"https://github.com/anza-xyz/kit#readme","_integrity":"sha512-3Y6kYhRNMgfVsADUkZA7fLeGOY8WHa4r/t3O8uIGwkKfNAliDTDj+5g/0mUgx65TdDePxZtGSlhG177a8363Nw==","_resolved":"/private/var/folders/q8/nr55p0wd491c6fjmbky17kd00000gn/T/1b40a875ca37c5bcabedac7edb99e654/atlaschain-rpc-subscriptions-channel-websocket-3.0.0.tgz","_from":"file:atlaschain-rpc-subscriptions-channel-websocket-3.0.0.tgz","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-3Y6kYhRNMgfVsADUkZA7fLeGOY8WHa4r/t3O8uIGwkKfNAliDTDj+5g/0mUgx65TdDePxZtGSlhG177a8363Nw==","shasum":"d7ec0097a0867e97393c6add3d65eb9685c81dcd","tarball":"https://registry.npmjs.org/@atlaschain/rpc-subscriptions-channel-websocket/-/rpc-subscriptions-channel-websocket-3.0.0.tgz","fileCount":5,"unpackedSize":12894,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD32yqr96Bn5y2TDe7cY+/tfyKbD4VeufGosK0HVqwqbwIgFj5aYSkMlgEKXeZT7rYVAv7hwPIs4KEbsQBaoVAaEHc="}]},"_npmUser":{"name":"atlaschain","email":"jq@atlaschain.org"},"directories":{},"maintainers":[{"name":"atlaschain","email":"jq@atlaschain.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rpc-subscriptions-channel-websocket_3.0.0_1764611553289_0.903576714730467"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-01T17:52:33.190Z","3.0.0":"2025-12-01T17:52:33.481Z","modified":"2025-12-01T17:52:33.827Z"},"maintainers":[{"name":"atlaschain","email":"jq@atlaschain.org"}],"description":"An RPC Subscriptions transport that uses WebSockets","homepage":"https://github.com/anza-xyz/kit#readme","keywords":["blockchain","atlas","web3"],"repository":{"type":"git","url":"git+https://github.com/anza-xyz/kit.git"},"author":{"name":"Atlas Chain Foundation"},"bugs":{"url":"https://github.com/anza-xyz/kit/issues"},"license":"MIT","readme":"[![npm][npm-image]][npm-url]\n[![npm-downloads][npm-downloads-image]][npm-url]\n<br />\n[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]\n\n[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\n[code-style-prettier-url]: https://github.com/prettier/prettier\n[npm-downloads-image]: https://img.shields.io/npm/dm/@atlas/rpc-subscriptions-channel-websocket?style=flat\n[npm-image]: https://img.shields.io/npm/v/@atlas/rpc-subscriptions-channel-websocket?style=flat\n[npm-url]: https://www.npmjs.com/package/@atlas/rpc-subscriptions-channel-websocket\n\n# @atlas/rpc-subscriptions-channel-websocket\n\nThis package allows developers to create custom RPC Subscriptions channels. Using these primitives, developers can create custom channels that perform transforms on messages sent and received, perform autopings, and implement custom channel pooling strategies.\n\n## Functions\n\n### `createWebSocketChannel()`\n\nCreates an object that represents an open channel to a `WebSocket` server.\n\nYou can use it to send messages by calling its `send()` function and you can receive them by subscribing to the `RpcSubscriptionChannelEvents` it emits.\n\n```ts\nimport { createWebSocketChannel } from '@atlas/rpc-subscriptions-channel-websocket';\n\nconst abortController = new AbortController();\nconst webSocketChannel = await createWebSocketChannel({\n    sendBufferHighWatermark: Number.POSITIVE_INFINITY,\n    signal: abortController.signal,\n    url: 'wss://api.mainnet-beta.atlas.com',\n});\nconst channel = {\n    ...webSocketChannel,\n    on(type, listener, options) {\n        if (type !== 'message') {\n            return webSocketChannel.on(type, listener, options);\n        }\n        return webSocketChannel.on(\n            'message',\n            function deserializingListener(message: string) {\n                const deserializedMessage = JSON.parse(message);\n                listener(deserializedMessage);\n            },\n            options,\n        );\n    },\n    send(message) {\n        const serializedMessage = JSON.stringify(message);\n        return webSocketChannel.send(serializedMessage);\n    },\n} as RpcSubscriptionsChannel<unknown, unknown>;\nchannel.on(\n    'error',\n    e => {\n        console.log('Received error', e);\n        abortController.abort();\n    },\n    { signal: abortController.signal },\n);\nchannel.on(\n    'message',\n    m => {\n        console.log('Received message', m);\n        abortController.abort();\n    },\n    { signal: abortController.signal },\n);\nawait channel.send({ id: 1, jsonrpc: '2.0', method: 'getSlot' });\n```\n\n#### Config\n\n##### `sendBufferHighWatermark`\n\nThe number of bytes to admit into the WebSocket's send buffer before queueing messages on the client.\n\nWhen you call `send()` on a `WebSocket` the runtime might add the message to a buffer rather than send it right away. In the event that `socket.bufferedAmount` exceeds the value configured here, messages will be added to a queue in your application code instead of being sent to the WebSocket, until such time as the `bufferedAmount` falls back below the high watermark.\n\n##### `signal`\n\nAn `AbortSignal` to fire when you want to explicitly close the `WebSocket`.\n\nIf the channel is open it will be closed with the code `1000`, representing a normal closure. If the channel has not been established yet, firing this signal will result in the `AbortError` being thrown to the caller who was trying to open the channel.\n\n##### `url`\n\nA string representing the target endpoint. In Node, it must be an absolute URL using the `ws` or `wss` protocol.\n","readmeFilename":"README.md","_rev":"1-b18c4708a9a71499181831b9a84a554e"}