Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e2233d2
refactor: replace dynamic xdr construction with static classes
Ryang-21 May 27, 2026
7f15314
refactor: add tests for new xdr classes / replace mocha-karma-sinon t…
Ryang-21 May 27, 2026
520e229
feat: modernize build chain and package configs
Ryang-21 May 27, 2026
d188fc3
refactor: optimize Writer class to use static buffer and ensure capac…
Ryang-21 May 27, 2026
7525f23
add missing exports
Ryang-21 May 27, 2026
3ddf1bf
add validateXdr method to XdrType interface and BaseType class
Ryang-21 May 27, 2026
7b0c982
add detailed JSDoc comments for XDR types and core classes
Ryang-21 May 27, 2026
fa86cfd
update examples to the new xdr schema
Ryang-21 May 27, 2026
acd054e
add migration guide and update changelog / readme
Ryang-21 May 27, 2026
4c20625
remove xdrgen codegen files
Ryang-21 May 27, 2026
6166c52
remove legacy configs that are no longer used
Ryang-21 May 27, 2026
309c5ac
update husky to v9
Ryang-21 May 27, 2026
070a969
expose nameByValue on EnumSchema
Ryang-21 May 28, 2026
fa8e38d
convert examples to typescript
Ryang-21 May 28, 2026
138961d
bump node version to 22
Ryang-21 May 28, 2026
cf85aff
add tests to validate new wire encode/decodes the same
Ryang-21 May 28, 2026
af7335f
address copilot feedback
Ryang-21 May 29, 2026
9b7352c
prep for rc.1
Ryang-21 May 29, 2026
e1db4db
add xdr test object with multi nested structure for compat testing
Ryang-21 Jun 1, 2026
e287a55
bump vitest to v4.1.0 and add vite as its no longer bundled with vitest
Ryang-21 Jun 1, 2026
15ef1f0
add pnpm workspace and define min release age for dependencies
Ryang-21 Jun 1, 2026
3093db2
fix naming of node 20 -> 22 and bump required pnpm version to 10
Ryang-21 Jun 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: '20.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
always-auth: true

Expand All @@ -35,6 +35,6 @@ jobs:
run: pnpm build && pnpm test

- name: Publish to npm
run: pnpm publish --access public --provenance --no-git-checks
run: pnpm publish --access public --provenance --no-git-checks --tag ${{ github.event.release.prerelease && 'rc' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js 20
- name: Use Node.js 22
uses: actions/setup-node@v3
with:
node-version: 20
node-version: 22

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 10

- name: Install Dependencies
run: pnpm install --frozen-lockfile
Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged
Comment thread
Ryang-21 marked this conversation as resolved.
Comment thread
Ryang-21 marked this conversation as resolved.
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,30 @@
All notable changes to this project will be documented in this file. This
project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
## [v5.0.0-rc.1](https://github.com/stellar/js-xdr/compare/v4.0.0...v5.0.0)

A complete rewrite of the library. The runtime `xdr.config(...)` schema-definition DSL has been replaced with a set of statically-typed, explicitly-declared schema builders, and the entire source has been migrated from JavaScript to TypeScript. See [MIGRATION.md](./MIGRATION.md) for a step-by-step upgrade guide.

### Breaking Change
* **Removed the dynamic `config` / `TypeBuilder` DSL.** Schemas are no longer built at runtime by resolving a graph of `Reference`s inside `xdr.config(...)`. Instead, you compose schemas directly from exported builder functions: `array`, `bool`, `double`, `enumType`, `fixedArray`, `float`, `int32`, `int64`, `lazy`, `opaque`, `option`, `string`, `struct`, `uint32`, `uint64`, `union`, `varOpaque`, and `void`. Forward/recursive references that the old DSL resolved automatically are now expressed explicitly with `lazy(() => schema)`.
* **Renamed the encode/decode API.** `toXDR()` / `fromXDR()` → `encode()` / `decode()`. The `format` argument (`'raw' | 'hex' | 'base64'`) has been dropped — `encode` always returns a `Uint8Array` and `decode` always takes one. Callers that relied on hex/base64 strings or `Buffer` output must convert at the boundary.
* **Updated validation APIs.** `validateXDR(input, format)` is now `validateXdr(bytes, options)` and accepts raw `Uint8Array` bytes only; callers that used hex/base64 validation must convert at the boundary first. The new `validate(value)` method checks whether a JavaScript value can be encoded by the schema.
* **`encode()` returns `Uint8Array` instead of `Buffer`.**
* **Renamed the low-level streaming types.** `XdrReader` → `Reader` and `XdrWriter` → `Writer`.
* **Consolidated the error types.** `XdrReaderError`, `XdrWriterError`, `XdrDefinitionError`, and `XdrNotImplementedDefinitionError` are replaced by a single `XdrError`.
* **Renamed/reshaped the numeric types.** `Int`/`UnsignedInt` → `int32`/`uint32` (return JS `number`); `Hyper`/`UnsignedHyper`/`LargeInt` → `int64`/`uint64` (return `bigint`, with range-checked encoding). The `Quadruple` type has been removed (it was already unsupported and threw on use).
* **New package layout.** `main`/`module`/`browser` fields are replaced by an `exports` map exposing dual ESM (`dist/js-xdr.mjs`) and CommonJS (`dist/js-xdr.cjs`) builds plus generated type declarations (`dist/js-xdr.d.ts`). Output is now `dist/` only (the `lib/` build is gone), the package is marked `sideEffects: false`, and Node `>=22` is required.

### Added
* **First-class TypeScript types.** Schemas carry full type information; `Infer<typeof schema>` yields the encoded/decoded value type, and `struct`/`union`/`enumType` produce strongly-typed object, tagged-union, and named-member types.
* **`lazy(() => schema)`** builder for defining recursive and forward-referencing schemas.
* **`BaseType` / `XdrType<T>`** are exported as the base class and interface for all schemas, along with a `DecodeOptions` `{ maxDepth }` option preserved from the prior recursion-depth guard.
* **`enumType` reserved-name and duplicate-value validation** — throws if a member name collides with a schema property (`name`, `kind`, `encode`, …) or if two members share a wire value.

### Changed
* **Build chain modernized:** Webpack + Babel → Rollup + esbuild; output is a clean dual ESM/CJS bundle with `.d.ts` emission via `rollup-plugin-dts`.
* **Test framework replaced:** Mocha + Karma + Sinon + Chai → Vitest; the full unit suite was rewritten in TypeScript (`*.test.ts`).
* **Linting modernized:** ESLint 8 (airbnb-base config) → ESLint 9 flat config (`eslint.config.mjs`) with `typescript-eslint`; added `pnpm lint` and `pnpm typecheck` scripts.

## [v4.0.0](https://github.com/stellar/js-xdr/compare/v3.1.2...v4.0.0)

Expand Down
8 changes: 0 additions & 8 deletions Gemfile

This file was deleted.

46 changes: 0 additions & 46 deletions Gemfile.lock

This file was deleted.

Loading
Loading