Headless Dropgate client library for file uploads and P2P transfers.
npm install @dropgate/core
A headless, environment-agnostic TypeScript library for Dropgate file sharing operations.
bash
npm install @dropgate/core
`
Builds
The package ships with multiple build targets:
| Format | File | Use Case |
| --- | --- | --- |
| ESM | dist/index.js | Modern bundlers, Node.js 18+ |
| CJS | dist/index.cjs | Legacy Node.js, CommonJS |
| Browser IIFE | dist/index.browser.js |
Or as an ES module:
`html
`
P2P Consumer Responsibilities
The P2P methods are headless. The consumer is responsible for:
1. Loading PeerJS: Provide the Peer constructor to p2pSend/p2pReceive
2. File Writing: Handle received chunks via onData callback (e.g., using streamSaver)
3. UI Updates: React to callbacks (onProgress, onStatus, etc.)
This design allows the library to work in any environment (browser, Electron, Node.js with WebRTC).
$3
The P2P implementation is designed for unlimited file sizes with constant memory usage:
- Stream-through architecture: Chunks flow immediately to onData, no buffering
- Flow control: Sender pauses when receiver's write queue backs up
- WebRTC reliability: SCTP provides reliable, ordered, checksum-verified delivery
> Note: For large files, always use the onData` callback approach rather than buffering in memory.