PLC Bundle V1 Example Implementations
TypeScript 100.0%
14 1 0

Clone this repository

https://tangled.org/atscan.net/plcbundle-ref https://tangled.org/did:plc:ft3tl5dxjn4psdk6asenqn3r/plcbundle-ref
git@tangled.org:atscan.net/plcbundle-ref git@tangled.org:did:plc:ft3tl5dxjn4psdk6asenqn3r/plcbundle-ref

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

PLC Bundle V1 Reference Implementation in TypeScript#

This script (plcbundle.ts) is a compact, readable reference implementation for creating PLC Bundle v1 archives. It fetches operations from the PLC directory and generates a complete, verifiable repository of data bundles.

It is fully compliant with the PLC Bundle v1 Specification.

Features#

  • Spec Compliant: Correctly implements hashing, chaining, serialization, and boundary de-duplication.
  • Reproducible: Generates byte-for-byte identical bundles to the official Go implementation.
  • Efficient: Uses a memory-efficient method to handle duplicates between bundle boundaries.
  • Standalone: Single-file script with clear dependencies.

Usage#

This script should run well on Bun (recommended), Deno, or Node.js.

The script accepts one optional argument: the path to the output directory where bundles will be stored. If omitted, it defaults to ./plc_bundles.

Bun is the fastest and easiest way to run this script, as it handles TypeScript and dependencies automatically.

# Install dependencies
bun install

# Run the script to create bundles in ./my_plc_bundles
bun run plcbundle.ts ./my_plc_bundles

Deno#

Deno can also run the script directly. You will need to provide permissions for network access and file system I/O.

# Run the script with Deno
deno run --allow-net --allow-read --allow-write plcbundle.ts ./my_plc_bundles

Node.js (with TypeScript)#

If using Node.js, you must first install dependencies and compile the TypeScript file to JavaScript.

# Install dependencies
npm install

# Compile the script
npx tsc

# Run the compiled JavaScript
node dist/plcbundle.js ./my_plc_bundles