{"_id":"@anycable/long-polling","_rev":"3-c213603caaa9edcb3faa7d3433d252bd","name":"@anycable/long-polling","dist-tags":{"latest":"0.4.0"},"versions":{"0.1.0":{"name":"@anycable/long-polling","version":"0.1.0","keywords":["anycable","actioncable"],"author":{"name":"Vladimir Dementyev"},"license":"MIT","_id":"@anycable/long-polling@0.1.0","maintainers":[{"name":"hellsquirrel","email":"zloymult@gmail.com"},{"name":"palkan","email":"dementiev.vm@gmail.com"}],"homepage":"https://anycable.io/","bugs":{"url":"https://github.com/anycable/anycable-client/issues"},"dist":{"shasum":"c945a6dad1defb0dc91e87f0da61c10fb7936948","tarball":"https://registry.npmjs.org/@anycable/long-polling/-/long-polling-0.1.0.tgz","fileCount":5,"integrity":"sha512-1XEXEghp0hMjz6i+ptkD0ppPdIDfSDzzTIrdS0YdOxAcV77b4zpFeJDJTXqVjLlN9uGf8IEtR4Vcu8HQpeR79w==","signatures":[{"sig":"MEUCIAfX4vWP4Ig45DRLidYMFJdRKCM4VIM8M4BGFo0jIjWTAiEAntgGGgdarRIqxsezIjBfGTFrTXRuIdKs42K9DBTlUe8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10250},"main":"index.js","type":"module","types":"./index.d.ts","engines":{"node":"^14.0.0 || >=16.0.0"},"exports":{".":"./index.js","./package.json":"./package.json"},"gitHead":"a17d08c3be8a5dd0a030256bcb7f55145cb5ba60","_npmUser":{"name":"palkan","email":"dementiev.vm@gmail.com"},"repository":{"url":"git+https://github.com/anycable/anycable-client.git","type":"git"},"_npmVersion":"9.6.7","description":"Long-polling transport for AnyCable client","directories":{},"sideEffects":false,"_nodeVersion":"20.3.0","dependencies":{"@anycable/core":"^0.7.0"},"_hasShrinkwrap":false,"devDependencies":{"node-fetch":"^2.6.0","@types/node-fetch":"^2.6.4"},"_npmOperationalInternal":{"tmp":"tmp/long-polling_0.1.0_1688011857844_0.8597805962727711","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@anycable/long-polling","version":"0.2.0","keywords":["anycable","actioncable"],"author":{"name":"Vladimir Dementyev"},"license":"MIT","_id":"@anycable/long-polling@0.2.0","maintainers":[{"name":"hellsquirrel","email":"zloymult@gmail.com"},{"name":"palkan","email":"dementiev.vm@gmail.com"}],"homepage":"https://anycable.io/","bugs":{"url":"https://github.com/anycable/anycable-client/issues"},"dist":{"shasum":"704697a72c3cf5c0249f71adb6c8de9077d6d502","tarball":"https://registry.npmjs.org/@anycable/long-polling/-/long-polling-0.2.0.tgz","fileCount":5,"integrity":"sha512-R7XASczG6Ot/gg9u2TmM57e/zyQzrNsiBove/XGQK2wrN1Dz901eEFtl8e0dBnewor+yhZTXZvgN9otBGKvpeA==","signatures":[{"sig":"MEQCIE5jVuvmzhiX0cyMlmV4CAI4NC5I2/LaiNgTMnglqFqtAiAH+HVxSmYiYy1EVvS2Lu3lN945yo/g9SI3JA/a2dvySQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10309},"main":"index.js","type":"module","types":"./index.d.ts","engines":{"node":"^14.0.0 || >=16.0.0"},"exports":{".":"./index.js","./package.json":"./package.json"},"gitHead":"d0dc3e477932d09b05ba8639ac86942bec8d2035","_npmUser":{"name":"palkan","email":"dementiev.vm@gmail.com"},"repository":{"url":"git+https://github.com/anycable/anycable-client.git","type":"git"},"_npmVersion":"10.2.4","description":"Long-polling transport for AnyCable client","directories":{},"sideEffects":false,"_nodeVersion":"21.6.0","dependencies":{"@anycable/core":"^0.8.0"},"_hasShrinkwrap":false,"devDependencies":{"node-fetch":"^2.6.0","@types/node-fetch":"^2.6.4"},"_npmOperationalInternal":{"tmp":"tmp/long-polling_0.2.0_1710441276937_0.037237864588193226","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@anycable/long-polling","version":"0.3.0","keywords":["anycable","actioncable"],"author":{"name":"Vladimir Dementyev"},"license":"MIT","_id":"@anycable/long-polling@0.3.0","maintainers":[{"name":"hellsquirrel","email":"zloymult@gmail.com"},{"name":"palkan","email":"dementiev.vm@gmail.com"}],"homepage":"https://anycable.io/","bugs":{"url":"https://github.com/anycable/anycable-client/issues"},"dist":{"shasum":"12493586fd11ea498859ed849f5e315351cc62de","tarball":"https://registry.npmjs.org/@anycable/long-polling/-/long-polling-0.3.0.tgz","fileCount":5,"integrity":"sha512-4YMI68JdIPrzvX2ETSPqNPS0mVu83vBOgtMLSQsPqtDT/aiQJm42KWlQDWLUataISg9jOUe5Y7WrQqFXyoGTYg==","signatures":[{"sig":"MEUCIB9F00cq24Yygeo7UloW/e1uxVcFAuq1ZUI/D/RXP1DlAiEAucya0Bynb8Yn2wkR3B4J/y3AsOXUH7Wuq49D1b/2yQk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10416},"main":"index.js","type":"module","types":"./index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":"./index.js","./package.json":"./package.json"},"gitHead":"560d7c740dac9aa548fa2edd932c0e85957ba836","_npmUser":{"name":"palkan","email":"dementiev.vm@gmail.com"},"repository":{"url":"git+https://github.com/anycable/anycable-client.git","type":"git"},"_npmVersion":"10.7.0","description":"Long-polling transport for AnyCable client","directories":{},"sideEffects":false,"_nodeVersion":"22.1.0","dependencies":{"@anycable/core":"^0.9.0"},"_hasShrinkwrap":false,"devDependencies":{"node-fetch":"^2.6.0","@types/node-fetch":"^2.6.4"},"_npmOperationalInternal":{"tmp":"tmp/long-polling_0.3.0_1716333352742_0.6704512792699036","host":"s3://npm-registry-packages"}},"0.4.0":{"name":"@anycable/long-polling","version":"0.4.0","description":"Long-polling transport for AnyCable client","engines":{"node":">=18.0.0"},"keywords":["anycable","actioncable"],"homepage":"https://anycable.io/","repository":{"type":"git","url":"git+https://github.com/anycable/anycable-client.git"},"author":{"name":"Vladimir Dementyev"},"license":"MIT","sideEffects":false,"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":"./index.js","./package.json":"./package.json"},"dependencies":{"@anycable/core":"^1.1.0"},"devDependencies":{"@types/node-fetch":"^2.6.4","node-fetch":"^2.6.0"},"_id":"@anycable/long-polling@0.4.0","gitHead":"bec3a8d1ce5f43a8ac4c791f8fca7c7307516b21","bugs":{"url":"https://github.com/anycable/anycable-client/issues"},"_nodeVersion":"20.18.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-+JwcaRIP8nikJSykrv+y0g/w2O0szVJXs8TBQUCVuhm9BNQc5IfPzafBj45wvtcbK2gHhbH9btBM86fEHd0RPw==","shasum":"0cd88eac7e1b0b9e6e315c573042dd434880b4c8","tarball":"https://registry.npmjs.org/@anycable/long-polling/-/long-polling-0.4.0.tgz","fileCount":5,"unpackedSize":10589,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB2JYUcno3PYWzbynjGx1X1B03vWo6pA73maqDo665mAAiEA0+bg7Z19gKlrVFwm0MfK6EYUvN9BsiTgnmpIQFc31r0="}]},"_npmUser":{"name":"palkan","email":"dementiev.vm@gmail.com"},"directories":{},"maintainers":[{"name":"hellsquirrel","email":"zloymult@gmail.com"},{"name":"palkan","email":"dementiev.vm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/long-polling_0.4.0_1740026590481_0.04048057806147609"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-29T04:10:57.765Z","modified":"2025-02-20T04:43:10.874Z","0.1.0":"2023-06-29T04:10:58.001Z","0.2.0":"2024-03-14T18:34:37.124Z","0.3.0":"2024-05-21T23:15:52.901Z","0.4.0":"2025-02-20T04:43:10.656Z"},"bugs":{"url":"https://github.com/anycable/anycable-client/issues"},"author":{"name":"Vladimir Dementyev"},"license":"MIT","homepage":"https://anycable.io/","keywords":["anycable","actioncable"],"repository":{"type":"git","url":"git+https://github.com/anycable/anycable-client.git"},"description":"Long-polling transport for AnyCable client","maintainers":[{"name":"hellsquirrel","email":"zloymult@gmail.com"},{"name":"palkan","email":"dementiev.vm@gmail.com"}],"readme":"[![npm version](https://badge.fury.io/js/%40anycable%2Flong-polling.svg)](https://badge.fury.io/js/%40anycable%2Flong-polling)\n\n# AnyCable Long Polling Transport\n\nThis package provides a long polling transport implementation for AnyCable.\n\nWhy long-polling in 202x? Even though WebSockets are widely supported, they still can be blocked by corporate firewalls and proxies. Long polling is a simplest alternative for such cases.\n\n**NOTE**: Server-side long-polling support is a part of AnyCable PRO.\n\n## Usage\n\nLong polling is consisered to be a fallback transport, so you need to configure it as follows:\n\n```js\nimport { createCable } from '@anycable/web'\nimport { LongPollingTransport } from '@anycable/long-polling'\n\n// Create a transport object and pass the URL to the AnyCable server's long polling endpoint\nconst lp = new LongPollingTransport('http://my.anycable.host/lp')\n\n// Pass the transport to the createCable or createConsumer function via the `fallbacks` option\nexport default createCable({fallbacks: [lp]})\n```\n\n### Using long polling as a primary transport\n\nYou can use long polling as a primary transport by specifying it via the `transport` option:\n\n```js\nimport { createCable } from '@anycable/web'\nimport { LongPollingTransport } from '@anycable/long-polling'\n\nconst transport = new LongPollingTransport('http://my.anycable.host/lp')\n\nexport default createCable({transport})\n```\n\n### Available options\n\nYou can pass the following options to the `LongPollingTransport` constructor (all options are optional, defaults are shown below):\n\n```js\nnew LongPollingTransport(\n  url,\n  {\n    cooldownPeriod: 500, // For how long (in ms) to wait before sending a new request\n    sendBuffer: 500, // For how long to buffer outgoing commands (in ms) before sending them to the server\n    pingInterval: 30000, // How often (in ms) to emit emulated ping messages (to make connection monitor think that the connection is alive)\n    credentials: 'same-origin', // Underlying fetch credentials\n    fetchImplementation: fetch, // A fetch-compatible implementation (e.g. node-fetch)\n  }\n)\n```\n\n**IMPORTANT:** When using `headers` as authentication method, we omit client's credentials when performing HTTP requests (`credential: \"omit\"` in `fetch`). When using `cookies`, we send cookies with the request (using `credentials: \"include\"` configuration). Keep this in mind if your clients authentication relies on cookies.\n\n## Legacy browsers support\n\nThis package uses [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) to perform requests and [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to cancel in-flight requests when necessary. Both APIs are not supported in legacy browsers (e.g., Internet Explorer). You must configure polyfills for them yourself. We recommend using [whatwg-fetch](https://github.com/github/fetch) and [abortcontroller-polyfill](https://github.com/mo/abortcontroller-polyfill) packages.\n\nSee also [anycable-browser-playground](https://github.com/anycable/anycable-browser-playground) project for a working example.\n","readmeFilename":"README.md"}