open-index/open-npm huggingface dataset:
npm package: @replit/protocol
Description: JavaScript bindings for the Replit protocol
Author: eng@replit.com
Latest version: 0.4.24

# @replit/protocol

JavaScript/TypeScript bindings for the Replit protocol.

## Tree-Shakeable ESM Build

This package now includes a tree-shakeable ES Module build alongside the existing CommonJS build.

### Usage

**Legacy namespace imports (default, fully backward compatible):**
```typescript
import { api } from '@replit/protocol';

// Access types via namespace
const target = api.DeploymentConfig.Target.VM;
const token = api.token.ReplToken.create({ ... });
```

This is the default import and works in all environments without configuration changes.

**Tree-shakeable ESM imports (recommended for new code in Next.js apps):**
```typescript
import { Persistence, ReplToken_WireFormat, Timestamp } from '@replit/protocol/esm';

// Direct access to types
const persistence: Persistence = Persistence.NONE;
const format: ReplToken_WireFormat = ReplToken_WireFormat.PROTOBUF;
```

⚠️ **Note**: ESM imports require adding `@replit/protocol` to `transpilePackages` in `next.config.js`:
```javascript
transpilePackages: ['@replit/protocol', /* other packages */]
```

**CommonJS (Node.js require):**
```typescript
const { api } = require('@replit/protocol');
const { Command } = api;
```

### Bundle Size Impact

The ESM build enables ~80-90% bundle size reduction through tree-shaking:
- **Full bundle**: ~848 KB
- **Single type import**: ~23 KB (96% reduction)

### Key Differences

- **Legacy namespace** (`@replit/protocol`): Uses `api.token.ReplToken`, imports everything
- **ESM direct imports** (`@replit/protocol/esm`): Uses `ReplToken_WireFormat`, tree-shakeable
- ESM uses protobuf-ts with `toBinary()`/`fromBinary()` instead of `encode()`/`decode()`
- ESM uses native `BigInt` instead of Long.js

# Developing
* Change goval/api/types.proto
* In this directory:
  * `pnpm build`
* Change repl-it-web/package.json:
  ```
  "@replit/protocol": "^0.4.9",
  ```
  to
  ```
  "@replit/protocol": "file:../goval/api/npm",
  ```
* Also change repl-it-web/shared/package.json:
  ```
  "@replit/protocol": "^0.4.9",
  ```
  to
  ```
  "@replit/protocol": "file:../../goval/api/npm",
  ```

# Publishing

After your `.proto` changes are merged:
- create a new branch
- cd into `api/npm`
- `pnpm --no-git-tag-version version <new-version>`
- submit a pull request
- merged
- pull latest `main`
- cd into `api/npm`
- `pnpm login` if you're not authed (will need to be in our npm org)
- `pnpm publish`
- it will run a build
- you be asked for 2fa
- package will be published
npm package: @replit/river-codegen
Description: codegenning river from grpc
Latest version: 0.1.4

# `@replit/river-codegen`

River (the name we're giving the protocol by which the Workspace and pid2 communicate) is heavily inspired by and is a superset of gRPC. River also supports something called "stream with initialization message" to avoid a case of a client-side stream being forced to be a union of an initialization message and a stream message (make invalid states unrepresentable and all that).

This codebase is a way to have some interoperability between gRPC and River's wire format. That way services can be declared using mostly stock gRPC and implemented in another language / binary (e.g. Python) and then their River declarations exported as an npm package and consumed as a client in another codebase. This means that a service can have a single gRPC declaration _and_ implementation with one adapter that can allow it to have a WebSockets River server.

## Usage

```shell
pnpm add @replit/river-codegen
pnpm exec river-codegen --include-path proto proto/service.proto
```

This will codegen the `service.proto` types that can be npm-packed and imported from repl-it-web.