@srcmap/codec 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +67 -0
  2. package/package.json +13 -10
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @srcmap/codec
2
+
3
+ [![npm](https://img.shields.io/npm/v/@srcmap/codec.svg)](https://www.npmjs.com/package/@srcmap/codec)
4
+ [![CI](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml/badge.svg)](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
5
+ [![Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/BartWaardenburg/srcmap/badges/coverage.json)](https://github.com/BartWaardenburg/srcmap/actions/workflows/coverage.yml)
6
+
7
+ High-performance VLQ source map codec powered by Rust via [NAPI](https://napi.rs).
8
+
9
+ Drop-in replacement for [`@jridgewell/sourcemap-codec`](https://github.com/jridgewell/sourcemap-codec). Encodes and decodes source map `mappings` strings as specified in [ECMA-426](https://tc39.es/ecma426/).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @srcmap/codec
15
+ ```
16
+
17
+ Prebuilt binaries are available for:
18
+ - macOS (x64, arm64)
19
+ - Linux (x64, arm64, glibc + musl)
20
+ - Windows (x64)
21
+
22
+ ## Usage
23
+
24
+ ```js
25
+ import { decode, encode } from '@srcmap/codec';
26
+
27
+ const decoded = decode('AAAA;AACA,EAAE');
28
+ // [
29
+ // [[0, 0, 0, 0]],
30
+ // [[0, 0, 1, 0], [2, 0, 0, 2]]
31
+ // ]
32
+
33
+ const encoded = encode(decoded);
34
+ // 'AAAA;AACA,EAAE'
35
+ ```
36
+
37
+ ## API
38
+
39
+ ### `decode(mappings: string): number[][][]`
40
+
41
+ Decode a VLQ-encoded mappings string into an array of lines, each containing an array of segments. Each segment is an array of 1, 4, or 5 numbers.
42
+
43
+ ### `encode(mappings: number[][][]): string`
44
+
45
+ Encode decoded mappings back into a VLQ string.
46
+
47
+ ### Segment format
48
+
49
+ | Fields | Meaning |
50
+ |--------|---------|
51
+ | `[genCol]` | Generated column only |
52
+ | `[genCol, srcIdx, origLine, origCol]` | With source mapping |
53
+ | `[genCol, srcIdx, origLine, origCol, nameIdx]` | With source mapping and name |
54
+
55
+ ## Compatibility
56
+
57
+ API-compatible with `@jridgewell/sourcemap-codec` — same function signatures, same output format. Can be used as a drop-in replacement.
58
+
59
+ ## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
60
+
61
+ High-performance source map tooling written in Rust. See also:
62
+ - [`@srcmap/sourcemap`](https://www.npmjs.com/package/@srcmap/sourcemap) - Source map parser (NAPI)
63
+ - [`@srcmap/sourcemap-wasm`](https://www.npmjs.com/package/@srcmap/sourcemap-wasm) - Source map parser (WASM)
64
+
65
+ ## License
66
+
67
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcmap/codec",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "High-performance VLQ source map codec powered by Rust",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -26,16 +26,17 @@
26
26
  "license": "MIT",
27
27
  "files": [
28
28
  "index.js",
29
- "index.d.ts"
29
+ "index.d.ts",
30
+ "README.md"
30
31
  ],
31
32
  "optionalDependencies": {
32
- "@srcmap/codec-darwin-x64": "0.1.1",
33
- "@srcmap/codec-darwin-arm64": "0.1.1",
34
- "@srcmap/codec-linux-x64-gnu": "0.1.1",
35
- "@srcmap/codec-linux-x64-musl": "0.1.1",
36
- "@srcmap/codec-linux-arm64-gnu": "0.1.1",
37
- "@srcmap/codec-linux-arm64-musl": "0.1.1",
38
- "@srcmap/codec-win32-x64-msvc": "0.1.1"
33
+ "@srcmap/codec-darwin-x64": "0.1.3",
34
+ "@srcmap/codec-darwin-arm64": "0.1.3",
35
+ "@srcmap/codec-linux-x64-gnu": "0.1.3",
36
+ "@srcmap/codec-linux-x64-musl": "0.1.3",
37
+ "@srcmap/codec-linux-arm64-gnu": "0.1.3",
38
+ "@srcmap/codec-linux-arm64-musl": "0.1.3",
39
+ "@srcmap/codec-win32-x64-msvc": "0.1.3"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@napi-rs/cli": "^3.0.0"
@@ -44,12 +45,14 @@
44
45
  "artifacts": "napi artifacts",
45
46
  "build": "napi build --release --platform",
46
47
  "build:debug": "napi build --platform",
48
+ "test": "node --test __tests__/codec.test.mjs",
49
+ "test:coverage": "mkdir -p coverage && node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-reporter=spec --test-reporter-destination=stdout __tests__/codec.test.mjs",
47
50
  "prepublishOnly": "napi prepublish -t npm",
48
51
  "version": "napi version"
49
52
  },
50
53
  "repository": {
51
54
  "type": "git",
52
- "url": "https://github.com/bartwaardenburg/srcmap"
55
+ "url": "git+https://github.com/BartWaardenburg/srcmap.git"
53
56
  },
54
57
  "keywords": [
55
58
  "sourcemap",